0

In a URL, according to this syntax, I want to use a different delimiter for separating path in a URL.

For example:

In this URL https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax, I want to separate wiki/Uniform_Resource_Identifier with a symbol other than /, but I want to make sure it does not break the URL syntax formalized by IETF.

I am only concerned about the path, how do I separate its components like wiki and Uniform_Resource_Identifier

Community
  • 1
  • 1
Spam Me
  • 33
  • 4
  • Why do you want to use another separator? – Nico Haase Dec 28 '20 at 20:49
  • Also, what makes you think that there **can** be another separator than the slash? Paragraph 3.3 does not list any other character to seperate path segments – Nico Haase Dec 28 '20 at 20:51
  • I am trying to store the path and `/` is not allowed.. – Spam Me Dec 28 '20 at 21:35
  • Then please share more details. Nobody can guess **how** you want to store that, and **why** the common identifier for seperating path segments should not be allowed – Nico Haase Dec 28 '20 at 21:40
  • I am trying to use Firebase which cannot use `/` for collection ID name. Check this https://firebase.google.com/docs/firestore/quotas#collections_documents_and_fields. – Spam Me Dec 28 '20 at 21:46

2 Answers2

0

You could use the URL encoding for / %2F

https://en.wikipedia.org/wiki%2FUniform_Resource_Identifier#Generic_syntax
  • That escaped character does not fulfill the same purpose – Nico Haase Dec 28 '20 at 20:51
  • That works, but the more common way is the other way round: Use slashes as delimiters and put `%2f` in the names that have "actual" slashes in them. Like `https://en.wikipedia.org/wiki/AC%2fDC`. (Wikipedia chose to use anything after the `wiki/` as a native slash, which is fine too as long as there's no nesting of pages). – chrysn Aug 13 '21 at 14:11
0

As far as your application's use of URIs is concerned, the / is barely more special than any other character, with two weak exceptions:

  • Using any character defined as delimiter (gen-delims and sub-delims in RFC3986) has, when used as your separator, the upside that you can optionally escape it. That means you can have a / in your name even if you separate your components by a slash, as in wiki/AC%2FDC (which has a component AC/DC after your application does the splitting), but just the same you can separate your components with a ; and still have wiki;Steins%3bGate for Steins;Gate.
  • Only when using relative references, then / are special in that you can do ../../ on slashes but not with any other delimiter. (And this is the only place where the path segments really matter).

So really, pick whichever you like for your application; the client should (at least under HATEOAS, or really general REST, assumptions) not put too much meaning to the components anyway.

chrysn
  • 810
  • 6
  • 19