{"_id":"encodeurl","_rev":"1675493","name":"encodeurl","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":"doug@somethingdoug.com"}],"time":{"modified":"2026-11-05T15:56:22.000Z","created":"2016-06-08T18:58:44.662Z","3.0.0":"2026-10-29T18:05:06.835Z","2.0.1":"2026-10-28T23:32:20.526Z","2.0.0":"2024-03-29T00:03:42.135Z","1.0.2":"2018-01-22T03:19:29.733Z","1.0.1":"2016-06-10T00:48:58.829Z","1.0.0":"2016-06-08T18:58:44.662Z"},"users":{"antixrist":true,"icodeforcookies":true,"mojaray2k":true,"mobeicaoyuan":true},"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"versions":{"3.0.0":{"_id":"encodeurl@3.0.0","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"3e6cdb0e25c24382b62ab06c115e9bf6044b87bd","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-3.0.0.tgz","integrity":"sha512-4McP5wRMkyFkj2+U0GfnZVjUQBSu+6kqbNhZsRqO1UeDVsdY8GDloc1bfAGHJ4MAVgJjo5RHveJA4fUZQMSMMA==","fileCount":6,"unpackedSize":10306,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/encodeurl@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHPxbSxv0EatWZmAsuNiPlxwgbxyUPs1I0jgwpP/KADfAiBvsLST0ARcIHVuX1/xoOWrRvVxBwN9G8Uc58R7QP9YSQ=="}],"size":3825,"noattachment":false,"key":"/encodeurl/-/encodeurl-3.0.0.tgz"},"main":"dist/index.js","name":"encodeurl","type":"module","engines":{"node":">=22"},"exports":"./dist/index.js","funding":{"url":"https://opencollective.com/express","type":"opencollective"},"gitHead":"0dc3870231fc7ea068830a66648c99453b4b1210","license":"MIT","scripts":{"lint":"ts-scripts check","size":"size-limit","test":"ts-scripts test && npm run size","bench":"vitest bench","build":"ts-scripts build","specs":"ts-scripts specs","format":"ts-scripts format","prepare":"ts-scripts install && npm run build"},"typings":"dist/index.d.ts","version":"3.0.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"4bc2b2a0-8b11-45d5-bd44-4bf444150e98"},"approver":{"name":"blakeembrey","email":"hello@blakeembrey.com"}},"homepage":"https://github.com/pillarjs/encodeurl#readme","keywords":["encode","encodeurl","url"],"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"size-limit":[{"path":"dist/index.js","limit":"250 B"}],"ts-scripts":{"dist":["dist"],"project":["tsconfig.build.json"]},"_npmVersion":"11.20.0","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"maintainers":[{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":"doug@somethingdoug.com"}],"_nodeVersion":"26.13.0","contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"publishConfig":{"access":"public"},"devDependencies":{"vitest":"^5.0.5","size-limit":"^14.3.0","typescript":"^7.0.2","@types/node":"^26.6.5","@vitest/coverage-v8":"^5.0.5","@borderless/ts-scripts":"^0.15.0","@size-limit/preset-small-lib":"^14.3.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/encodeurl_3.0.0_1793297106737_0.7777954163779673"},"_hasShrinkwrap":false,"publish_time":1793297106835,"_cnpm_publish_time":1793297106835},"2.0.1":{"name":"encodeurl","version":"2.0.1","keywords":["encode","encodeurl","url"],"license":"MIT","_id":"encodeurl@2.0.1","maintainers":[{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":"doug@somethingdoug.com"}],"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"homepage":"https://github.com/pillarjs/encodeurl#readme","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"f268548822bd87b5b4fdce83c56388c6d33c9de6","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-2.0.1.tgz","fileCount":4,"integrity":"sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==","signatures":[{"sig":"MEUCIQDcMaEQelYrMUcLMsxDG/G2MlpQqw35iKQp+sRimSa32QIgZLgwfqpmO74QjA5QdXU/ItIr8k4UGjRrbDlBVFyirzc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIER04ogw96r8Vl7jM5e3RYqsnD/DV+vF68LgYupb/6oVAiBaTX2IPEIFWOK0Krlz4nTRJNF/E5C6QdIOIQfqk2K0cg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7582,"size":3234,"noattachment":false,"key":"/encodeurl/-/encodeurl-2.0.1.tgz"},"engines":{"node":">= 0.8"},"funding":{"url":"https://opencollective.com/express","type":"opencollective"},"gitHead":"0bac92effa0f1d103b7c05b52d7ac69b19ee09a1","scripts":{"lint":"eslint .","test":"mocha --check-leaks --reporter spec","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_npmUser":{"name":"blakeembrey","email":"hello@blakeembrey.com"},"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"_npmVersion":"11.20.0","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"_nodeVersion":"26.12.1","_hasShrinkwrap":false,"devDependencies":{"nyc":"~17.1.0","mocha":"~11.7.0","eslint":"5.11.1","eslint-plugin-node":"7.0.1","eslint-plugin-import":"2.14.0","eslint-plugin-promise":"4.0.1","eslint-config-standard":"12.0.0","eslint-plugin-standard":"4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/encodeurl_2.0.1_1793230340423_0.9350537235339887","host":"s3://npm-registry-packages-npm-production"},"publish_time":1793230340526,"_cnpm_publish_time":1793230340526},"2.0.0":{"name":"encodeurl","version":"2.0.0","keywords":["encode","encodeurl","url"],"license":"MIT","_id":"encodeurl@2.0.0","maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":"doug@somethingdoug.com"}],"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"homepage":"https://github.com/pillarjs/encodeurl#readme","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"7b8ea898077d7e409d3ac45474ea38eaf0857a58","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-2.0.0.tgz","fileCount":4,"integrity":"sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==","signatures":[{"sig":"MEUCIBOFos/fjObZakhslwkYNCRgy3lxta+k4AJdNDf+lDfaAiEArFwkiXZR7H08jnrMnVmch2fkcCs8hSToYkixEEgpsVA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6980,"size":3020,"noattachment":false,"key":"/encodeurl/-/encodeurl-2.0.0.tgz"},"engines":{"node":">= 0.8"},"gitHead":"5f2205efe622fc7972c4e45ed7cbe7f8d652c299","scripts":{"lint":"eslint .","test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"_npmUser":{"name":"blakeembrey","email":"hello@blakeembrey.com"},"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"_npmVersion":"10.2.0","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"_nodeVersion":"21.0.0","_hasShrinkwrap":false,"devDependencies":{"mocha":"2.5.3","eslint":"5.11.1","istanbul":"0.4.5","eslint-plugin-node":"7.0.1","eslint-plugin-import":"2.14.0","eslint-plugin-promise":"4.0.1","eslint-config-standard":"12.0.0","eslint-plugin-standard":"4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/encodeurl_2.0.0_1711670621995_0.1569270866269692","host":"s3://npm-registry-packages"},"publish_time":1711670622135,"_cnpm_publish_time":1711670622135},"1.0.2":{"name":"encodeurl","version":"1.0.2","keywords":["encode","encodeurl","url"],"license":"MIT","_id":"encodeurl@1.0.2","maintainers":[{"name":"dougwilson","email":"doug@somethingdoug.com"}],"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"homepage":"https://github.com/pillarjs/encodeurl#readme","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-1.0.2.tgz","integrity":"sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==","signatures":[{"sig":"MEQCIEZEF05/h8gAqiJeucYt7VIMp4ayOLGGiaSmLeIMoTJaAiBsN6tnzH2TNdHb1t534W4ruVnBCH4JYlrPwgiZ6g+doA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":3260,"noattachment":false,"key":"/encodeurl/-/encodeurl-1.0.2.tgz"},"_from":".","files":["LICENSE","HISTORY.md","README.md","index.js"],"_shasum":"ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59","engines":{"node":">= 0.8"},"gitHead":"1a7301e330bf20fd7c8c173102315e45cd1f5d1e","scripts":{"lint":"eslint .","test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"_npmVersion":"3.10.10","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"_nodeVersion":"6.11.1","devDependencies":{"mocha":"2.5.3","eslint":"3.19.0","istanbul":"0.4.5","eslint-plugin-node":"5.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-promise":"3.6.0","eslint-config-standard":"10.2.1","eslint-plugin-standard":"3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/encodeurl-1.0.2.tgz_1516591169672_0.5424360500182956","host":"s3://npm-registry-packages"},"publish_time":1516591169733,"_cnpm_publish_time":1516591169733},"1.0.1":{"name":"encodeurl","version":"1.0.1","keywords":["encode","encodeurl","url"],"license":"MIT","_id":"encodeurl@1.0.1","maintainers":[{"name":"dougwilson","email":"doug@somethingdoug.com"}],"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"homepage":"https://github.com/pillarjs/encodeurl#readme","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"79e3d58655346909fe6f0f45a5de68103b294d20","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-1.0.1.tgz","integrity":"sha512-Emsft8lNRSZ7+fFm2KgTM8OZPcfHip/hNMSkje83n+LqPx5tI4xkCxyunJIG3EZsWHz9sqzohiPR6monRXWD8g==","signatures":[{"sig":"MEUCIC+1JQNva4PG/Yd7Hun0ETOL3Bs2U9ozuiFqQsCo5UeTAiEAtMd8khtEYg95K7dXUYK7TeUEL9gdbJJBtOlh0/vH8Jo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":3099,"noattachment":false,"key":"/encodeurl/-/encodeurl-1.0.1.tgz"},"_from":".","files":["LICENSE","HISTORY.md","README.md","index.js"],"_shasum":"79e3d58655346909fe6f0f45a5de68103b294d20","engines":{"node":">= 0.8"},"gitHead":"39ed0c235fed4cea7d012038fd6bb0480561d226","scripts":{"lint":"eslint **/*.js","test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"repository":{"url":"git+https://github.com/pillarjs/encodeurl.git","type":"git"},"_npmVersion":"2.15.1","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"_nodeVersion":"4.4.3","devDependencies":{"mocha":"2.5.3","eslint":"2.11.1","istanbul":"0.4.3","eslint-plugin-promise":"1.3.2","eslint-config-standard":"5.3.1","eslint-plugin-standard":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/encodeurl-1.0.1.tgz_1465519736251_0.09314409433864057","host":"packages-12-west.internal.npmjs.com"},"publish_time":1465519738829,"_cnpm_publish_time":1465519738829},"1.0.0":{"name":"encodeurl","version":"1.0.0","keywords":["encode","encodeurl","url"],"license":"MIT","_id":"encodeurl@1.0.0","maintainers":[{"name":"dougwilson","email":"doug@somethingdoug.com"}],"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"homepage":"https://github.com/pillarjs/encodeurl","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"dist":{"shasum":"7cfb78e36a241593379e2ebad3926783dc18e058","tarball":"http://registry-npm.ywwl.com/encodeurl/download/encodeurl-1.0.0.tgz","integrity":"sha512-t7dshuwL0l+kfCkwsQufpTKS2QpamJxUAxvdo+icEyV76RY/BhaD57Cla6WJC1Mz9IYOH3mhen6fkKLsKR3i8g==","signatures":[{"sig":"MEQCICyABqpPt4hfx3fn3M7tnJkT73DR2s0t7dmJu6ZnysyKAiABuh+UpHoyWFCg1MxnB8WyTcGRWs2fPMoR5+t9sK3mjA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":3072,"noattachment":false,"key":"/encodeurl/-/encodeurl-1.0.0.tgz"},"_from":".","files":["LICENSE","HISTORY.md","README.md","index.js"],"_shasum":"7cfb78e36a241593379e2ebad3926783dc18e058","engines":{"node":">= 0.8"},"gitHead":"b3f2a3a74af20c4b27f0466782d80fb0685feb47","scripts":{"lint":"eslint **/*.js","test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"repository":{"url":"https://github.com/pillarjs/encodeurl","type":"git"},"_npmVersion":"1.4.28","description":"Encode a URL to a percent-encoded form, excluding already-encoded sequences","directories":{},"devDependencies":{"mocha":"2.5.3","eslint":"2.11.1","istanbul":"0.4.3","eslint-plugin-promise":"1.3.2","eslint-config-standard":"5.3.1","eslint-plugin-standard":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/encodeurl-1.0.0.tgz_1465412322161_0.9512871925253421","host":"packages-12-west.internal.npmjs.com"},"publish_time":1465412324662,"_cnpm_publish_time":1465412324662}},"readme":"# Encode URL\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][ci-image]][ci-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nEncode a URL to a percent-encoded form, excluding already-encoded sequences.\n\n## Installation\n\n```sh\nnpm install encodeurl\n```\n\n## API\n\n```js\nimport { encodeUrl } from \"encodeurl\";\n```\n\nRequires Node.js 22 or later. TypeScript declarations are included.\n\n### encodeUrl(url)\n\nEncode a URL to a percent-encoded form, excluding already-encoded sequences.\n\nThis function accepts a URL and encodes all the non-URL code points (as UTF-8 byte sequences). It will not encode the \"%\" character unless it is not part of a valid sequence (`%20` will be left as-is, but `%foo` will be encoded as `%25foo`).\n\nThis encode is meant to be \"safe\" and does not throw errors. It will try as hard as it can to properly encode the given URL, including replacing any raw, unpaired surrogate pairs with the Unicode replacement character prior to encoding.\n\n## Examples\n\n### Encode a URL containing user-controlled data\n\n```js\nimport { encodeUrl } from \"encodeurl\";\nimport escapeHtml from \"escape-html\";\n\nhttp.createServer(function onRequest(req, res) {\n  // get encoded form of inbound url\n  var url = encodeUrl(req.url);\n\n  // create html message\n  var body = \"<p>Location \" + escapeHtml(url) + \" not found</p>\";\n\n  // send a 404\n  res.statusCode = 404;\n  res.setHeader(\"Content-Type\", \"text/html; charset=UTF-8\");\n  res.setHeader(\"Content-Length\", String(Buffer.byteLength(body, \"utf-8\")));\n  res.end(body, \"utf-8\");\n});\n```\n\n### Encode a URL for use in a header field\n\n```js\nimport { encodeUrl } from \"encodeurl\";\nimport escapeHtml from \"escape-html\";\nimport * as url from \"node:url\";\n\nhttp.createServer(function onRequest(req, res) {\n  // parse inbound url\n  var href = url.parse(req);\n\n  // set new host for redirect\n  href.host = \"localhost\";\n  href.protocol = \"https:\";\n  href.slashes = true;\n\n  // create location header\n  var location = encodeUrl(url.format(href));\n\n  // create html message\n  var body = \"<p>Redirecting to new site: \" + escapeHtml(location) + \"</p>\";\n\n  // send a 301\n  res.statusCode = 301;\n  res.setHeader(\"Content-Type\", \"text/html; charset=UTF-8\");\n  res.setHeader(\"Content-Length\", String(Buffer.byteLength(body, \"utf-8\")));\n  res.setHeader(\"Location\", location);\n  res.end(body, \"utf-8\");\n});\n```\n\n## Similarities\n\nThis function is _similar_ to the intrinsic function `encodeURI`. However, it will not encode:\n\n- The `\\`, `^`, or `|` characters\n- The `%` character when it's part of a valid sequence\n- `[` and `]` (for IPv6 hostnames)\n- Replaces raw, unpaired surrogate pairs with the Unicode replacement character\n\nAs a result, the encoding aligns closely with the behavior in the [WHATWG URL specification][whatwg-url]. However, this package only encodes strings and does not do any URL parsing or formatting.\n\nIt is expected that any output from `new URL(url)` will not change when used with this package, as the output has already been encoded. Additionally, if we were to encode before `new URL(url)`, we do not expect the before and after encoded formats to be parsed any differently.\n\n## Testing\n\n```sh\n$ npm install\n$ npm test\n$ npm run build\n```\n\n## References\n\n- [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax][rfc-3986]\n- [WHATWG URL Living Standard][whatwg-url]\n\n[rfc-3986]: https://tools.ietf.org/html/rfc3986\n[whatwg-url]: https://url.spec.whatwg.org/\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/encodeurl\n[npm-url]: https://npmjs.org/package/encodeurl\n[downloads-image]: https://img.shields.io/npm/dm/encodeurl\n[downloads-url]: https://npmcharts.com/compare/encodeurl?minimal=true\n[ci-image]: https://img.shields.io/github/actions/workflow/status/pillarjs/encodeurl/ci.yml?branch=master\n[ci-url]: https://github.com/pillarjs/encodeurl/actions/workflows/ci.yml\n[coveralls-image]: https://img.shields.io/coverallsCoverage/github/pillarjs/encodeurl?branch=master\n[coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master\n","_attachments":{},"homepage":"https://github.com/pillarjs/encodeurl#readme","bugs":{"url":"https://github.com/pillarjs/encodeurl/issues"},"license":"MIT"}