{"name":"micromark-util-sanitize-uri","version":"1.0.0","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","micromark-util-encode":"^1.0.0","micromark-util-symbol":"^1.0.0"},"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},"homepage":"https://github.com/micromark/micromark/tree/main#readme","_id":"micromark-util-sanitize-uri@1.0.0","_nodeVersion":"16.2.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-cCxvBKlmac4rxCGx6ejlIviRaMKZc0fWm5HdCHEeDWRSkn44l6NdYVRyU+0nT1XC72EQJMZV8IPHF+jTr56lAg==","shasum":"27dc875397cd15102274c6c6da5585d34d4f12b2","tarball":"http://registry-npm.ywwl.com/micromark-util-sanitize-uri/download/micromark-util-sanitize-uri-1.0.0.tgz","fileCount":6,"unpackedSize":13311,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0jQ6CRA9TVsSAnZWagAAFpYP/j0fqDL9zBQvQxpX6aYo\nk5QFxZ5ttZA57R3qIfekQjTe++Kj+VVweTM+yTSBmo8wBVNtX698PQ2XzfGG\neUTTDskVNpxHVlt4nLdYQwMSTzWwEx/5kC3Zroo+nAegovk4pYspmaUORJ8D\n6dHGVEXuJ5UybYW91Y+5Mup8x9Y9tp3Z/JDGq4l1VdwUQprBi7qcRYkBvRmt\n6SLEqA2MoV8eDGyvV0rJpi6Pv4q3YQu71t7CdA4Yj07x3nwLmM1mizmu6YFh\ntrjSXv3rGO23Jpta0KYlP5tLTXIcv6DE7XcivpeqsuzAonHWfHGTtfjXDwdn\nJSVOahZmcuWrpYHljjlTLn6zRuZ9gkzO1nggvERUbXnZ2nXCsmS9qV26Tmd/\nq+IPbL4QxS4AnQ983dGo92fJPdo+4ObGLf8tSGvYb0QcyYT7JGEus1LOGCEp\nLgWyLkukWazG3HtjH602f4EP7OqK/8DQv6O04BduCYiznb//+CfZTQdBYdcI\nsli6eaeFb+9w6YZEyXY/CAyD9PfmltgUo9F39JgsHzaE+ULDBTx6l3Bc6ZVT\nZKZfn4LQculRlcyYQKoNU17DY1MUuy8HmZeCKZLtAaezObiEt/LfJs6nLSLI\nAEvMokM3hjPDoHC1QA2lRUaskFV0KhayXie6FN4Tep3heSVh1wJc+1wjZe39\n69db\r\n=U3r4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEQ0xRgaq9RKOqo2oh1oyUhHkaRny+AVDm0HUJiB9qt9AiEAmmGyPRV1MxMIutxmzs7cqvKGZfX87Md1E3dLB3hTMv8="}],"size":3201,"noattachment":false,"key":"/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.0.0.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_1624388665641_0.9808958540879873"},"_hasShrinkwrap":false,"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\n[micromark][] utility to sanitize urls.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`normalizeUri(value)`](#normalizeurivalue)\n    *   [`sanitizeUri(url[, pattern])`](#sanitizeuriurl-pattern)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package exposes an algorithm to make URLs safe.\n\n## When should I use this?\n\nThis package might be useful when you are making your own micromark extensions.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install micromark-util-sanitize-uri\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {sanitizeUri} from 'https://esm.sh/micromark-util-sanitize-uri@1'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {sanitizeUri} from 'https://esm.sh/micromark-util-sanitize-uri@1?bundle'\n</script>\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 identifiers [`normalizeUri`][api-normalize-uri] and\n[`sanitizeUri`][api-sanitize-uri].\nThere is no default export.\n\n### `normalizeUri(value)`\n\nNormalize a URL.\n\nEncode unsafe characters with percent-encoding, skipping already encoded\nsequences.\n\n###### Parameters\n\n*   `value` (`string`)\n    — URI to normalize\n\n###### Returns\n\nNormalized URI (`string`).\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`][api-normalize-uri]).\nFurther unsafe characters are encoded as character references (see\n[`micromark-util-encode`][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`)\n    — URI to sanitize\n*   `pattern` (`RegExp`, optional)\n    — allowed protocols\n\n###### Returns\n\nSanitized URI (`string`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`micromark-util-sanitize-uri@^2`, compatible with Node.js 16.\nThis package works with `micromark@^3`.\n\n## Security\n\nThis package is safe.\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/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-sanitize-uri\n\n[bundle-size]: https://bundlejs.com/?q=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[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\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/main/security.md\n\n[contributing]: https://github.com/micromark/.github/blob/main/contributing.md\n\n[support]: https://github.com/micromark/.github/blob/main/support.md\n\n[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md\n\n[typescript]: https://www.typescriptlang.org\n\n[micromark]: https://github.com/micromark/micromark\n\n[micromark-util-encode]: https://github.com/micromark/micromark/tree/main/packages/micromark-util-encode\n\n[api-normalize-uri]: #normalizeurivalue\n\n[api-sanitize-uri]: #sanitizeuriurl-pattern\n","publish_time":1624388665833,"_cnpm_publish_time":1624388665833,"dist-tags":{"latest":"2.0.1","next":"1.0.0-beta.1"}}