4

After researching Google and SO, there seems to be conflicting opinions on this.

We have run-in to a problem with Google Chrome substituting | separator as %7C, whereas Firefox and Safari do not.

Here's an example:

http://www.example.com/page1|sub-page2|sub-page-3

Are there any strict rules to follow when choosing a separator character for semantic URLs and are there any strong arguments against (or workarounds when) using |?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Richard Tinkler
  • 1,635
  • 3
  • 21
  • 41
  • Where are you using it that it's 'displayed', and differently across browsers? – OJFord Apr 01 '14 at 15:53
  • If they're sub-pages, it should be `/`, if that was a typo, well, you've used `-` in `sub-page`, so why not use that instead of `|` too? – OJFord Apr 01 '14 at 15:57
  • 1
    See also (same OP): [How to prevent Google Chrome and IE substituting '|' in URL with %7C](http://stackoverflow.com/q/22787919/1591669) – unor Apr 01 '14 at 16:08

2 Answers2

3

| is not a valid character in a URL. Modern browsers will silently encode it to %7C when sending, and may or may not display this change in the address bar. Similarly, servers will silently decode the character for you.

This would have been a problem in last millennium, where browsers would crash just because you didn't specify http://, but today you can just use whatever you want and the browser will take care of it. However, automatic parsers such as http://example.com/test|fish Markdown may not agree to it being a valid URL. In this case, it looks like it does, but try that on my forums and it will complain at you.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
1

Internet explorer/chrome use url encoding when displaying the url in the address bar after a page request has been made, %7C is the safe way of displaying a pipe ('|') so its not a problem that chrome is doing this.

as a cheeky fix to make all browsers behave the same way, why not use %7C as your separator from the get-go, instead of a pipe, and then all browsers should interpret this as a pipe for you behind the scenes, but display it as &7C in the address bar.

FlemGrem
  • 814
  • 4
  • 9