/ never-odd-or-even / back / node_modules / mdurl /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[   ]package.json2 years ago1.3K 
[TXT]CHANGELOG.md10 years ago229  
[   ]decode.js10 years ago2.8K 
[   ]LICENSE10 years ago2.2K 
[TXT]README.md10 years ago3.4K 
[   ]parse.js10 years ago9.7K 
[   ]index.js10 years ago195  
[   ]format.js10 years ago514  
[   ]encode.js10 years ago2.2K 
README.md

mdurl

Build Status NPM version

URL utilities for markdown-it parser.

API

.encode(str [, exclude, keepEncoded]) -> String

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:

encode.defaultChars, encode.componentChars

You can use these constants as second argument to encode function.

For example, encode('something', encode.componentChars, true) is roughly the equivalent of the encodeURIComponent() function (except encode() doesn't throw).

.decode(str [, exclude]) -> String

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:

decode.defaultChars, decode.componentChars

You can use these constants as second argument to decode function.

For example, decode('something', decode.defaultChars) has the same behavior as decodeURI('something') on a correctly encoded input.

.parse(url, slashesDenoteHost) -> urlObs

Parse url string. Similar to node's url.parse, but without any normalizations and query string parse.

Result (hash):

Difference with node's url:

  1. No leading slash in paths, e.g. in url.parse('http://foo?bar') pathname is ``, not /
  2. Backslashes are not replaced with slashes, so http:\\example.org\ is treated like a relative path
  3. Trailing colon is treated like a part of the path, i.e. in http://example.org:foo pathname is :foo
  4. Nothing is URL-encoded in the resulting object, (in joyent/node some chars in auth and paths are encoded)
  5. url.parse() does not have parseQueryString argument
  6. Removed extraneous result properties: host, path, query, etc., which can be constructed using other parts of the url.

.format(urlObject)

Format an object previously obtained with .parse() function. Similar to node's url.format.

License

MIT

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80