root 3bf41bf355 update | пре 1 година | |
---|---|---|
.. | ||
CHANGELOG.md | пре 1 година | |
LICENSE | пре 1 година | |
README.md | пре 1 година | |
decode.js | пре 1 година | |
encode.js | пре 1 година | |
format.js | пре 1 година | |
index.js | пре 1 година | |
package.json | пре 1 година | |
parse.js | пре 1 година |
URL utilities for markdown-it parser.
Percent-encode a string, avoiding double encoding. Don't touch /a-zA-Z0-9/
+
excluded chars + /%[a-fA-F0-9]{2}/
(if not disabled). Broken surrorates are
replaced with U+FFFD
.
Params:
;/?:@&=+$,-_.!~*'()#
. Additional chars to keep intact
(except /a-zA-Z0-9/
).true
. By default it skips already encoded sequences
(/%[a-fA-F0-9]{2}/
). If set to false
, %
will be encoded.You can use these constants as second argument to encode
function.
encode.defaultChars
is the same exclude set as in the standard encodeURI()
functionencode.componentChars
is the same exclude set as in the encodeURIComponent()
functionFor example, encode('something', encode.componentChars, true)
is roughly the equivalent of
the encodeURIComponent()
function (except encode()
doesn't throw).
Decode percent-encoded string. Invalid percent-encoded sequences (e.g. %2G
)
are left as is. Invalid UTF-8 characters are replaced with U+FFFD
.
Params:
;/?:@&=+$,#
.You can use these constants as second argument to decode
function.
decode.defaultChars
is the same exclude set as in the standard decodeURI()
functiondecode.componentChars
is the same exclude set as in the decodeURIComponent()
functionFor example, decode('something', decode.defaultChars)
has the same behavior as
decodeURI('something')
on a correctly encoded input.
Parse url string. Similar to node's url.parse, but without any normalizations and query string parse.
//
, expect a hostname after it. Optional, false
.Result (hash):
Difference with node's url
:
url.parse('http://foo?bar')
pathname is
`, not
/`http:\\example.org\
is
treated like a relative pathhttp://example.org:foo
pathname is :foo
url.parse()
does not have parseQueryString
argumenthost
, path
, query
, etc.,
which can be constructed using other parts of the url.Format an object previously obtained with .parse()
function. Similar to node's
url.format.