@@ -103,21 +103,33 @@ Tootpick tries to recover from that and do the right thing.
103
103
104
104
## Fragment parameters
105
105
106
+ Although Tootpick currently only uses a single parameter, ` text ` , it is ready
107
+ for accepting more than that.
108
+
106
109
The parsing of the URI fragment, that is part after the ` # ` , is done as
107
- described in the [ Media Fragments URI specification ] ( https://www.w3.org/TR/media-frags/#processing-name-value-components ) .
108
- This provides broad compatibility with existing RFC 3986 compatible URI
109
- encoding routines . (Note: Tootpick does not use media fragments, just the
110
- syntax for parameters in URI fragments.)
110
+ described in the [ Media Fragments URI
111
+ specification ] ( https://www.w3.org/TR/media-frags/#processing-name-value-components )
112
+ which assumes RFC 3986 URI escaping . (Note: Tootpick does not use media
113
+ fragments, just the syntax for parameters in URI fragments.)
111
114
112
115
This means that the reserved characters ` & ` and ` = ` are used as delimiters.
113
116
They must be unescaped when used as delimiters, and must be escaped when used
114
- as a key or value. Additionally, ` + ` , while "reserved", is not treated as a
115
- special character, which means that a space must be encoded as ` %20 ` , not ` + ` .
116
- RFC 3986 URI encoding functions always encode spaces as ` %20 ` .
117
+ in a key or value. The fragment must not be encoded as a whole, because that
118
+ would encode the delimiters as well; only its part should be individually
119
+ encoded. Additionally, ` + ` , while "reserved", is not treated as a special
120
+ character, which means that a space must be encoded as ` %20 ` , not ` + ` like in RFC . RFC 3986
121
+ URI encoding functions always encode spaces as ` %20 ` .
117
122
118
123
Most programming languages come with a function that does the right thing
119
124
for use with Tootpick.
120
125
126
+ ``` JavaScript
127
+ // JavaScript example
128
+ document .location = ' https://tootpick.org/#text=' + encodeURIComponent (
129
+ document .title + ' ' + document .URL
130
+ );
131
+ ```
132
+
121
133
| Language | Function |
122
134
| ---------- | ------------------------------------ |
123
135
| Go | url.PathEscape() from net/url |
0 commit comments