Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valid URL separators

Tags:

I have a long URL with several values.

Example 1:

http://www.domain.com/list?seach_type[]=0&search_period[]=1&search_min=3000&search_max=21000&search_area=6855%3B7470%3B7700%3B7730%3B7741%3B7742%3B7752%3B7755%3B7760%3B7770%3B7800%3B7840%3B7850%3B7860%3B7870%3B7884%3B7900%3B7950%3B7960%3B7970%3B7980%3B7990%3B8620%3B8643%3B8800%3B8830%3B8831%3B8832%3B8840%3B8850%3B8860%3B8881%3B9620%3B9631%3B9632 

My variable search area contains only 4 number digits (example 4000, 5000), but can contain a lot of them. Right now I seperate these in the URL by using ; as separator symbol. Though as seen in Example 1, the ; is converted into %3B. This makes me believe that this is a bad symbol to use.

What is the best URL separator?

like image 208
Kristian Avatar asked Oct 05 '10 20:10

Kristian


People also ask

What is a separator in URL?

The question mark is used as a separator, and is not part of the query string. Web frameworks may provide methods for parsing multiple parameters in the query string, separated by some delimiter. In the example URL below, multiple query parameters are separated by the ampersand, " & ": https://example.com/path/to/page?

What characters are valid in URL?

A URL is composed from a limited set of characters belonging to the US-ASCII character set. These characters include digits (0-9), letters(A-Z, a-z), and a few special characters ( "-" , "." , "_" , "~" ).

Can you have spaces in URL?

Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format. URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. URLs cannot contain spaces.


2 Answers

Moontear, I think you have misread the linked document. That limitation only applies to the "scheme" portion of the URL. In the case of WWW URLs, that is the "http".

The next section of the document goes on to say:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

I'd personally use comma (,). However, plus (+) and dash (-) are both reasonable options as well.

BTW, that document also mentions that semi-colon (;) is reserved in some schemes.

like image 166
GinoA Avatar answered Sep 20 '22 05:09

GinoA


Well, according to RFC1738, valid URLs may only contain the letters a-z, the plus sign (+), period and hyphen (-).

Generally I would go with a plus to separate your search areas. So your URL would become http://www.domain.com/list?seach_type=0&search_period=1&search_min=3000&search_max=21000&search_area=6855+7470+7700+...

--EDIT--

As GinoA pointed out I misread the document. Hence "$-_.+!*'()," are valid characters too. I'd still go with the + sign though.

like image 24
Dennis G Avatar answered Sep 17 '22 05:09

Dennis G