{"name":"micromark-util-sanitize-uri","version":"1.0.0-alpha.2","description":"micromark utility to sanitize urls","license":"MIT","keywords":["micromark","util","utility","sanitize","clear","url"],"repository":{"type":"git","url":"git+https://github.com/micromark/micromark.git#main"},"bugs":{"url":"https://github.com/micromark/micromark/issues"},"funding":[{"type":"GitHub Sponsors","url":"https://github.com/sponsors/unifiedjs"},{"type":"OpenCollective","url":"https://opencollective.com/unified"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"dev/index.d.ts","exports":{"development":"./dev/index.js","default":"./index.js"},"dependencies":{"micromark-util-character":"^1.0.0-alpha.2","micromark-util-encode":"^1.0.0-alpha.2","micromark-util-symbol":"^1.0.0-alpha.2"},"scripts":{"build":"rimraf \"*.d.ts\" \"{dev/,lib/}**/*.d.ts\" && tsc && micromark-build && type-coverage"},"xo":false,"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"readme":"# micromark-util-sanitize-uri\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][bundle-size-badge]][bundle-size]\n[![Sponsors][sponsors-badge]][opencollective]\n[![Backers][backers-badge]][opencollective]\n[![Chat][chat-badge]][chat]\n\nmicromark utility to sanitize urls.\n\n## Contents\n\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`sanitizeUri(url[, pattern])`](#sanitizeuriurl-pattern)\n*   [Security](#security)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install micromark-util-sanitize-uri\n```\n\n## Use\n\n```js\nimport {sanitizeUri} from 'micromark-util-sanitize-uri'\n\nsanitizeUri('https://example.com/a&amp;b') // 'https://example.com/a&amp;amp;b'\nsanitizeUri('https://example.com/a%b') // 'https://example.com/a%25b'\nsanitizeUri('https://example.com/a%20b') // 'https://example.com/a%20b'\nsanitizeUri('https://example.com/👍') // 'https://example.com/%F0%9F%91%8D'\nsanitizeUri('https://example.com/', /^https?$/i) // 'https://example.com/'\nsanitizeUri('javascript:alert(1)', /^https?$/i) // ''\nsanitizeUri('./example.jpg', /^https?$/i) // './example.jpg'\nsanitizeUri('#a', /^https?$/i) // '#a'\n```\n\n## API\n\nThis module exports the following identifiers: `sanitizeUri`.\nThere is no default export.\n\n### `sanitizeUri(url[, pattern])`\n\nMake a value safe for injection as a URL.\n\nThis encodes unsafe characters with percent-encoding and skips already\nencoded sequences (see `normalizeUri` internally).\nFurther unsafe characters are encoded as character references (see\n`micromark-util-encode`).\n\nA regex of allowed protocols can be given, in which case the URL is sanitized.\nFor example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or\n`/^https?$/i` for `img[src]` (this is what `github.com` allows).\nIf the URL includes an unknown protocol (one not matched by `protocol`, such\nas a dangerous example, `javascript:`), the value is ignored.\n\n###### Parameters\n\n*   `url` (`string`) — URI to sanitize.\n*   `pattern` (`RegExp`, optional) — Allowed protocols.\n\n###### Returns\n\n`string` — Sanitized URI.\n\n## Security\n\nSee [`security.md`][securitymd] in [`micromark/.github`][health] for how to\nsubmit a security report.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`micromark/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organisation, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg\n\n[build]: https://github.com/micromark/micromark/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg\n\n[coverage]: https://codecov.io/github/micromark/micromark\n\n[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-sanitize-uri.svg\n\n[downloads]: https://www.npmjs.com/package/micromark-util-sanitize-uri\n\n[bundle-size-badge]: https://img.shields.io/bundlephobia/minzip/micromark-util-sanitize-uri.svg\n\n[bundle-size]: https://bundlephobia.com/result?p=micromark-util-sanitize-uri\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[opencollective]: https://opencollective.com/unified\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/micromark/micromark/discussions\n\n[license]: https://github.com/micromark/micromark/blob/main/license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/micromark/.github\n\n[securitymd]: https://github.com/micromark/.github/blob/HEAD/security.md\n\n[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/micromark/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md\n","readmeFilename":"readme.md","homepage":"https://github.com/micromark/micromark/tree/main#readme","_id":"micromark-util-sanitize-uri@1.0.0-alpha.2","_nodeVersion":"16.2.0","_npmVersion":"7.15.1","dist":{"integrity":"sha512-197W6iYAejKSYvtI1QOAT+YffdlQLHTPUUfKoLUNZk5BDl0cEzumwl06uFv9K2UPJccSzJNp2p/1WKp7b4gsbw==","shasum":"646830439078c4a82a0a5f8867abe05f57a53887","tarball":"http://registry-npm.ywwl.com/micromark-util-sanitize-uri/download/micromark-util-sanitize-uri-1.0.0-alpha.2.tgz","fileCount":6,"unpackedSize":13343,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgviDNCRA9TVsSAnZWagAAovYP/3NbX+K6VJxkfkGbJtut\nGx46Ho+uZaLFh7+tTgtHqvC+zfTdyElKdtYCgXRPS+qKeNFpX66u+qeNcSge\nL/+HSb0pDkAX8ldyLZeHpSNDdw+ToIofXPt1ljTfkwiHKdj/ML7ruXMHteES\n6oDbL08khCapsKbckmLushz95c1Mrz4wkaelCDUUO5u6m6ukZj912j/nSo4a\njIBA7jJY75iKqgKuROrTxvVpCoHNGT1hcmmW+z5vK+k3A72dUBMVzpvPAtvE\nHIh5Kd+XSBesucVEkMDiUOEIAGoT0qJpgKJU/heKNiP+K1s/1uIjsf+RtGT3\n/6ql4oR6MNT9p3Us093e6Mh5birYgAcsr/Rp7ZYuELv3XY1v6+62A79wWWSA\nqP9PfIE4m0c2edagPjN0gZ+PCzpt8EW065Zl9CSMV+zh6dF7K/+f84+nfmoC\nDmZHg+6xa9LyQxb00O8UXXAUfgW7Cq5anKMQXKo+M1XKWVPRy/xQ2XlVAbZV\n/DyUTTmM/nDFByfG878Qd+mDh+PQegVb9D8RfwOKdbN71TCeyIcCzfkWcFOF\nxdiHR8eDbOkYy88OEbsjhFydDiC1Y/HSFqJqcBUD2e8D5qZT9wLL/9FIOZRJ\nFEHVlOiSmSfyJ97+Pp12Si1s908cQ5X7MQRkCa1IctPzoT0jNuHwRDq51XPX\n7tW2\r\n=p4VE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB96M6VfAYdPT+0cK1m71cK0U1j6987CtjW2riEQ2IPgAiBsxJPnjdxkI7pwmDeApLWfYwEh7G+CjD95bFoihIZ9JQ=="}],"size":3208,"noattachment":false,"key":"/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.0.0-alpha.2.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/micromark-util-sanitize-uri_1.0.0-alpha.2_1623072973506_0.5577131944861855"},"_hasShrinkwrap":false,"publish_time":1623072973652,"_cnpm_publish_time":1623072973652,"dist-tags":{"latest":"2.0.1","next":"1.0.0-beta.1"}}