Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of valid characters for the fragment identifier in an URL?

I'm using the fragment identifier to create a permalink for AJAX events in my web app similar to this guy. Something like:

http://www.myapp.com/calendar#filter:year/2010/month/5 

I've done quite a bit of searching but can't find a list of valid characters for the fragment idenitifer. The W3C spec doesn't offer anything.

Do I need to encode the characters the same as the URL in has in general?

There doesn't seem to be any good information on this anywhere.

like image 532
sohtimsso1970 Avatar asked May 17 '10 14:05

sohtimsso1970


People also ask

What are valid characters in a 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 ( "-" , "." , "_" , "~" ).

What is the fragment of a URL?

A fragment is an internal page reference, sometimes called a named anchor. It usually appears at the end of a URL and begins with a hash (#) character followed by an identifier. It refers to a section within a web page. In HTML documents, the browser looks for an anchor tag with a name attribute matching the fragment.

How do you define a fragment identifier?

The fragment identifier is a string after URI, after the hash, which identifies something specific as a function of the document. For a user interface Web document such as HTML poage, it typically identifies a part or view. For example in the object http://foo/bar#frag. the string "frag" is the fragment identifier.


1 Answers

See the RFC 3986.

fragment    = *( pchar / "/" / "?" ) pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"     unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" pct-encoded   = "%" HEXDIG HEXDIG sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"                  / "*" / "+" / "," / ";" / "=" 

So you can use !, $, &, ', (, ), *, +, ,, ;, =, something matching %[0-9a-fA-F]{2}, something matching [a-zA-Z0-9], -, ., _, ~, :, @, /, and ?

like image 113
Artefacto Avatar answered Oct 06 '22 13:10

Artefacto