Valid URL fragment (#) for valid characters

After some digging on the Internet, I was not able to find a good answer for what characters I can use for the URL fragment. I am writing a javascript script that will use URL fragments.

I wanted to make the URL easy to view without having it too complicated. So I was wondering if I can use characters like ":,?" Or "!". in the url fragment and still have it.

My URL fragment should contain the following values:

  • order by
    • identifier
    • desc or asc
  • way
    • // full / ran / path / here /
+3
source share
2 answers

TL; DR

:

  • 0 - 9
  • a - z
  • a - z
  • ? / : @ - . _ ~ ! $ & ' ( ) * + , ; =
  • (a %, )

?

URI STD 66, RFC 3986.

, .

3.5:

fragment = *( pchar / "/" / "?" )

, ( )

  • , pchar
  • /
  • ?

pchar

A., , pchar:

pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

,

  • , unreserved
  • , pct-
  • ,
  • :
  • @

unreserved

, :

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

  • , ALPHA
  • , DIGIT
  • -
  • .
  • _
  • ~

ALPHA DIGIT

, ALPHA DIGIT. , ABNF, 1.3:

ALPHA (), [...] DIGIT ( ) [...]

,

  • a - z, a - z
  • 0 - 9

pct-encoded

, pct-encoded:

pct-encoded = "%" HEXDIG HEXDIG

.

sub-delims

, -:

sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="

  • !
  • $
  • &
  • '
  • (
  • )
  • *
  • +
  • ,
  • ;
  • =
+10

, , , , .

:

  • "!"
  • "$"
  • "&"
  • "'"
  • "("
  • ")"
  • "*"
  • "+"
  • ""
  • ""
  • "="
  • "?"
  • "@"
  • ALPHA
  • "-"
  • ""
  • "_"
  • "~"
  • "%" HEXDIG HEXDIG
  • ":"
  • "/"
0

Source: https://habr.com/ru/post/1615179/


All Articles