Skip to content

Commit 7e1a852

Browse files
committed
Update README.md
1 parent 96d51f9 commit 7e1a852

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,33 @@ Tootpick tries to recover from that and do the right thing.
103103

104104
## Fragment parameters
105105

106+
Although Tootpick currently only uses a single parameter, `text`, it is ready
107+
for accepting more than that.
108+
106109
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.)
111114

112115
This means that the reserved characters `&` and `=` are used as delimiters.
113116
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`.
117122

118123
Most programming languages come with a function that does the right thing
119124
for use with Tootpick.
120125

126+
```JavaScript
127+
// JavaScript example
128+
document.location = 'https://tootpick.org/#text=' + encodeURIComponent(
129+
document.title + ' ' + document.URL
130+
);
131+
```
132+
121133
| Language | Function |
122134
| ---------- | ------------------------------------ |
123135
| Go | url.PathEscape() from net/url |

0 commit comments

Comments
 (0)