0

I'm trying to compress the GET query of a url by using a character map to decode the url on the server side. Currently when I submit a form the url becomes like below:

http://localhost:8080/seminars?0=&1=&2=&3=&4=&5=&6=&7=&8=&9=&a=&b=&c=&d=&e=&f=&g=&h=&i=&j=&k=&l=&m=&n=&o=&p=&q=&r=&s=&t=&u=&v=

A part of html that corresponds to this looks like below:

<form id="filterForm" action="localhost:8080/seminars" method="GET"></form>
<input form="filterForm" type="checkbox" name="a" value="">some text
<input form="filterForm" type="checkbox" name="0" value="">some text
<input form="filterForm" type="checkbox" name="5" value="">some text

This produces the unnecessary "=" that can be removed. The query part should look like: ?0&1&2&3&4

Is it possible?

Silver Flash
  • 871
  • 3
  • 7
  • 16
  • Possible to use POST ? – AloHA_ChiCken Mar 24 '21 at 03:19
  • not at the moment. I can only do gets – Silver Flash Mar 24 '21 at 03:22
  • If so, the one solution I have at the moment is to like concat ?0=&1|ab|ac|ad|ad ... where ab and ac could be value or indicator where the value comes from or input id(s). This mean you pass all inputs into one value. – AloHA_ChiCken Mar 24 '21 at 03:29
  • Or you could refer to this post https://stackoverflow.com/questions/43548725/pass-url-parameter-without-question-mark-and-equal-sign – AloHA_ChiCken Mar 24 '21 at 03:34
  • @AloHA_ChiCken thank you for the post. It doesn't provide a good use case for me. Your idea is better, but would require effort into creating the concatenated string and then splitting it apart in the server. – Silver Flash Mar 24 '21 at 03:41
  • @JonP I didn't know that, do you have a source? Are there any adverse effects with these 2 distinctions? I am using laravel/nginx for the server. – Silver Flash Mar 24 '21 at 03:42
  • What's wrong with what you showed in the question, `0&1&2&...`? PHP will treat that as equivalent to `0=&1=&2=...` I think most other middleware will do the same. – Barmar Mar 24 '21 at 03:54
  • Actually, ignore me, miss understood the question. The single character keys confused me. – Jon P Mar 24 '21 at 03:59
  • Not sure if viable for what you need, but you could give all the check boxes the same name, giving them the value of what you have as name at the moment. Any checked boxes values are then a comma delimted string as the value for the Query String key. E.g: ?cmap=a,5, given a name of cmap – Jon P Mar 24 '21 at 04:09

0 Answers0