版博士V2.0程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # mdurl
  2. [![Build Status](https://img.shields.io/travis/markdown-it/mdurl/master.svg?style=flat)](https://travis-ci.org/markdown-it/mdurl)
  3. [![NPM version](https://img.shields.io/npm/v/mdurl.svg?style=flat)](https://www.npmjs.org/package/mdurl)
  4. > URL utilities for [markdown-it](https://github.com/markdown-it/markdown-it) parser.
  5. ## API
  6. ### .encode(str [, exclude, keepEncoded]) -> String
  7. Percent-encode a string, avoiding double encoding. Don't touch `/a-zA-Z0-9/` +
  8. excluded chars + `/%[a-fA-F0-9]{2}/` (if not disabled). Broken surrorates are
  9. replaced with `U+FFFD`.
  10. Params:
  11. - __str__ - input string.
  12. - __exclude__ - optional, `;/?:@&=+$,-_.!~*'()#`. Additional chars to keep intact
  13. (except `/a-zA-Z0-9/`).
  14. - __keepEncoded__ - optional, `true`. By default it skips already encoded sequences
  15. (`/%[a-fA-F0-9]{2}/`). If set to `false`, `%` will be encoded.
  16. ### encode.defaultChars, encode.componentChars
  17. You can use these constants as second argument to `encode` function.
  18. - `encode.defaultChars` is the same exclude set as in the standard `encodeURI()` function
  19. - `encode.componentChars` is the same exclude set as in the `encodeURIComponent()` function
  20. For example, `encode('something', encode.componentChars, true)` is roughly the equivalent of
  21. the `encodeURIComponent()` function (except `encode()` doesn't throw).
  22. ### .decode(str [, exclude]) -> String
  23. Decode percent-encoded string. Invalid percent-encoded sequences (e.g. `%2G`)
  24. are left as is. Invalid UTF-8 characters are replaced with `U+FFFD`.
  25. Params:
  26. - __str__ - input string.
  27. - __exclude__ - set of characters to leave encoded, optional, `;/?:@&=+$,#`.
  28. ### decode.defaultChars, decode.componentChars
  29. You can use these constants as second argument to `decode` function.
  30. - `decode.defaultChars` is the same exclude set as in the standard `decodeURI()` function
  31. - `decode.componentChars` is the same exclude set as in the `decodeURIComponent()` function
  32. For example, `decode('something', decode.defaultChars)` has the same behavior as
  33. `decodeURI('something')` on a correctly encoded input.
  34. ### .parse(url, slashesDenoteHost) -> urlObs
  35. Parse url string. Similar to node's [url.parse](http://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost), but without any
  36. normalizations and query string parse.
  37. - __url__ - input url (string)
  38. - __slashesDenoteHost__ - if url starts with `//`, expect a hostname after it. Optional, `false`.
  39. Result (hash):
  40. - protocol
  41. - slashes
  42. - auth
  43. - port
  44. - hostname
  45. - hash
  46. - search
  47. - pathname
  48. Difference with node's `url`:
  49. 1. No leading slash in paths, e.g. in `url.parse('http://foo?bar')` pathname is
  50. ``, not `/`
  51. 2. Backslashes are not replaced with slashes, so `http:\\example.org\` is
  52. treated like a relative path
  53. 3. Trailing colon is treated like a part of the path, i.e. in
  54. `http://example.org:foo` pathname is `:foo`
  55. 4. Nothing is URL-encoded in the resulting object, (in joyent/node some chars
  56. in auth and paths are encoded)
  57. 5. `url.parse()` does not have `parseQueryString` argument
  58. 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
  59. which can be constructed using other parts of the url.
  60. ### .format(urlObject)
  61. Format an object previously obtained with `.parse()` function. Similar to node's
  62. [url.format](http://nodejs.org/api/url.html#url_url_format_urlobj).
  63. ## License
  64. [MIT](https://github.com/markdown-it/mdurl/blob/master/LICENSE)