{"_id":"url-safe-string","_rev":"6-95c720f2eda08d393d68d5d4104208bd","name":"url-safe-string","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"url-safe-string","version":"1.0.0","keywords":["URL safe String","URL-safe","String to URL","String to URL tag","text to URL safe tag"],"author":{"url":"http://ard.ninja","name":"Aaron Decker","email":"aaron@ard.ninja"},"license":"ISC","_id":"url-safe-string@1.0.0","maintainers":[{"name":"a-r-d","email":"aaron@ard.ninja"}],"homepage":"https://github.com/a-r-d/url-safe-string#readme","bugs":{"url":"https://github.com/a-r-d/url-safe-string/issues"},"dist":{"shasum":"14a5055981124fc720217b1f4f96c0b6e8c9a874","tarball":"https://registry.npmjs.org/url-safe-string/-/url-safe-string-1.0.0.tgz","integrity":"sha512-5jd1Lti1Jcu9mUYnKRjtb2QFL792QL//XihckkouSzbWLQbzd7JV8dF16Mm6R+fJ2X/17aMyMldHgixIO9TvPQ==","signatures":[{"sig":"MEQCIGFJ1niI7aIlqxRqvyJF51gUTXBuaNNf3m5j5Xm1CT2SAiAdmpHCltFmFe0Pvgq68Vi+ABlo442Pe+DWrmqovqbt4g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"url-safe-string.js","_from":".","_shasum":"14a5055981124fc720217b1f4f96c0b6e8c9a874","gitHead":"0cf6c19fe7f52ed7207f7907378d48105b269ac8","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"a-r-d","email":"aaron@ard.ninja"},"repository":{"url":"git+https://github.com/a-r-d/url-safe-string.git","type":"git"},"_npmVersion":"3.3.12","description":"Dependency free node module to convert strings to URL-safe tags for client side routing, SEO purposes, or, whatever else.","_nodeVersion":"5.2.0","devDependencies":{"mocha":"^2.3.4"},"directories":{}},"1.1.0":{"name":"url-safe-string","version":"1.1.0","keywords":["URL safe String","URL-safe","String to URL","String to URL tag","text to URL safe tag"],"author":{"url":"http://ard.ninja","name":"Aaron Decker","email":"aaron@ard.ninja"},"license":"ISC","_id":"url-safe-string@1.1.0","maintainers":[{"name":"a-r-d","email":"aaron@ard.ninja"}],"homepage":"https://github.com/a-r-d/url-safe-string#readme","bugs":{"url":"https://github.com/a-r-d/url-safe-string/issues"},"dist":{"shasum":"2ab1852922b56d209553adb204812fc5009042ba","tarball":"https://registry.npmjs.org/url-safe-string/-/url-safe-string-1.1.0.tgz","integrity":"sha512-1SytB3qGX+JEMRtZYHrw42/NBos+PLkkEBRANmheVvtGfqarwXwqsO/l7xOUA29UA7kg5L7HINAXGWNVDfYmIA==","signatures":[{"sig":"MEYCIQD/Q9zqHPZ22O/95aUS22HSSgCm2LFXJRbGm71XRlSBAQIhAPSDQrS4yvzPwbiyRZKDVPaAactmlLGHXmtdzIDJSVT/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"url-safe-string.js","_from":".","_shasum":"2ab1852922b56d209553adb204812fc5009042ba","engines":{"node":">=4.0"},"gitHead":"351b224beb3b54459bf1950267de154bea140bed","scripts":{"test":"mocha"},"_npmUser":{"name":"a-r-d","email":"aaron@ard.ninja"},"repository":{"url":"git+https://github.com/a-r-d/url-safe-string.git","type":"git"},"_npmVersion":"3.9.2","description":"Dependency free node module to convert strings to URL-safe tags for client side routing, SEO purposes, or, whatever else.","_nodeVersion":"6.2.0","devDependencies":{"mocha":"^2.3.4"},"_npmOperationalInternal":{"tmp":"tmp/url-safe-string-1.1.0.tgz_1467505695844_0.3037936487235129","host":"packages-12-west.internal.npmjs.com"},"directories":{}},"2.0.0":{"name":"url-safe-string","version":"2.0.0","engines":{"node":">=14"},"description":"Dependency free module to convert strings into URL-safe slugs. Use for routing, SEO, permalinks, or any place you need a clean, URL-friendly string.","main":"url-safe-string.js","module":"index.mjs","types":"index.d.ts","exports":{".":{"import":"./index.mjs","require":"./url-safe-string.js","types":"./index.d.ts"}},"scripts":{"test":"vitest run"},"repository":{"type":"git","url":"git+https://github.com/a-r-d/url-safe-string.git"},"keywords":["url","slug","slugify","url-safe","url-slug","url-friendly","sanitize","permalink","seo","routing","string","tag","clean-url","text-to-slug","hyphenate","parameterize","URL safe String","String to URL","String to URL tag","text to URL safe tag"],"author":{"name":"Aaron Decker","email":"aaron@ard.ninja","url":"http://ard.ninja"},"license":"ISC","bugs":{"url":"https://github.com/a-r-d/url-safe-string/issues"},"homepage":"https://github.com/a-r-d/url-safe-string#readme","devDependencies":{"vitest":"^3.1.1"},"_id":"url-safe-string@2.0.0","gitHead":"b42afa885b40ead514e42427c198bc7344955e72","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-klvi0PMwj5yLokf8XzOUvBwdO270JLQNB2IcYaxZhLxkDoD1yn98PMGuFD1KwfE2fe/EJQ9ZohtWlOoc6CTysA==","shasum":"8921e54f9ea16920d8963f5311b2f1409752dabf","tarball":"https://registry.npmjs.org/url-safe-string/-/url-safe-string-2.0.0.tgz","fileCount":5,"unpackedSize":13468,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDShaFnhnQhqXymfcvW3hQI3p9Y3x+4hZUcYJj4mxCPoQIhAOIpvOLC4/eqXsSuVnRrTbM6qg99enbCXXmuAH2NmDFZ"}]},"_npmUser":{"name":"a-r-d","email":"aaron@ard.ninja"},"directories":{},"maintainers":[{"name":"a-r-d","email":"aaron@ard.ninja"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/url-safe-string_2.0.0_1774375188081_0.26195835863076766"},"_hasShrinkwrap":false}},"time":{"created":"2016-01-23T01:40:25.259Z","modified":"2026-03-24T17:59:48.397Z","1.0.0":"2016-01-23T01:40:25.259Z","1.1.0":"2016-07-03T00:28:18.231Z","2.0.0":"2026-03-24T17:59:48.285Z"},"bugs":{"url":"https://github.com/a-r-d/url-safe-string/issues"},"author":{"name":"Aaron Decker","email":"aaron@ard.ninja","url":"http://ard.ninja"},"license":"ISC","homepage":"https://github.com/a-r-d/url-safe-string#readme","keywords":["url","slug","slugify","url-safe","url-slug","url-friendly","sanitize","permalink","seo","routing","string","tag","clean-url","text-to-slug","hyphenate","parameterize","URL safe String","String to URL","String to URL tag","text to URL safe tag"],"repository":{"type":"git","url":"git+https://github.com/a-r-d/url-safe-string.git"},"description":"Dependency free module to convert strings into URL-safe slugs. Use for routing, SEO, permalinks, or any place you need a clean, URL-friendly string.","maintainers":[{"name":"a-r-d","email":"aaron@ard.ninja"}],"readme":"# url-safe-string\n\n[![CI](https://github.com/a-r-d/url-safe-string/actions/workflows/ci.yml/badge.svg)](https://github.com/a-r-d/url-safe-string/actions/workflows/ci.yml) [![npm version](https://badge.fury.io/js/url-safe-string.svg)](https://badge.fury.io/js/url-safe-string)\n\n[![NPM](https://nodei.co/npm/url-safe-string.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/url-safe-string/)\n\nZero-dependency module to convert strings into URL-safe slugs. Use for routing, SEO, permalinks, or anywhere you need a clean, URL-friendly string.\n\n## Install\n\n```bash\nnpm install url-safe-string\n```\n\n## Usage\n\n### CommonJS\n\n```javascript\nconst UrlSafeString = require('url-safe-string');\nconst tagGenerator = new UrlSafeString();\n\ntagGenerator.generate('Hello World!');\n// 'hello-world'\n\ntagGenerator.generate('Some Book Name Here!', 'Some authors Name', 'Publisher or something...');\n// 'some-book-name-here-some-authors-name-publisher-or-something'\n\n// Accented characters are transliterated automatically\ntagGenerator.generate('München Straße');\n// 'muenchen-strasse'\n\ntagGenerator.generate('Crème brûlée à la française');\n// 'creme-brulee-a-la-francaise'\n\ntagGenerator.generate('El Niño São Paulo');\n// 'el-nino-sao-paulo'\n```\n\n### ES Modules\n\n```javascript\nimport UrlSafeString from 'url-safe-string';\n\nconst tagGenerator = new UrlSafeString();\ntagGenerator.generate('Hello World!');\n// 'hello-world'\n```\n\n### TypeScript\n\n```typescript\nimport UrlSafeString from 'url-safe-string';\n\nconst tagGenerator = new UrlSafeString({ maxLen: 50, lowercaseOnly: true });\nconst tag: string = tagGenerator.generate('Hello World!');\n```\n\n## Options\n\nThese are the default options, which can all be overridden by passing an object into the constructor.\n\n```javascript\nconst tagGenerator = new UrlSafeString({\n  maxLen: 100,                          // truncates beyond maxLen\n  lowercaseOnly: true,                  // convert to lowercase\n  regexRemovePattern: /((?!([a-z0-9])).)/gi, // matches opposite of [a-z0-9]\n  joinString: '-',                      // separator: '-', '_', '~', etc.\n  trimWhitespace: true,                 // trim input strings\n  trimResult: true,                     // strip leading/trailing join strings\n  transliterate: true,                  // convert accented chars to ASCII (ö -> oe)\n  transliterations: { '&': 'and' }      // custom character mappings\n});\n```\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `maxLen` | `number` | `100` | Maximum length of the output string |\n| `lowercaseOnly` | `boolean` | `true` | Convert output to lowercase |\n| `regexRemovePattern` | `RegExp` | `/((?!([a-z0-9])).)/gi` | Pattern for characters to remove |\n| `joinString` | `string` | `'-'` | String used to join words and replace whitespace |\n| `trimWhitespace` | `boolean` | `true` | Trim leading/trailing whitespace from inputs |\n| `trimResult` | `boolean` | `true` | Strip leading/trailing join strings from the output |\n| `transliterate` | `boolean` | `true` | Transliterate accented/special characters to ASCII equivalents (e.g. `ö` -> `oe`, `ñ` -> `n`, `ß` -> `ss`). Covers German, French, Spanish, Portuguese, Nordic, Polish, Czech, and Romanian characters. |\n| `transliterations` | `object` | `{}` | Custom character mapping merged on top of the defaults (e.g. `{ '&': 'and', '@': 'at' }`) |\n\n### Static method\n\nIf you don't need custom options, you can skip the constructor:\n\n```javascript\nconst UrlSafeString = require('url-safe-string');\n\nUrlSafeString.generate('Hello World!');\n// 'hello-world'\n\nUrlSafeString.generate('München Straße');\n// 'muenchen-strasse'\n```\n\n## Tests\n\n```bash\nnpm test\n```\n\n## Upgrading\n\n### v1.x to v2.0\n\nThe API is fully backwards compatible. No code changes are needed. The major version bump reflects the modernized tooling, new transliteration behavior, and minimum Node.js version change.\n\n**Note on transliteration:** v2.0 transliterates accented characters by default (e.g. `ö` -> `oe`). In v1.x these characters were silently stripped. This means output may differ for inputs containing accented characters -- the new output is more correct and SEO-friendly. If you need the old behavior, set `transliterate: false`.\n\nIf you are on Node.js 14 or later (released 2020), v2.0 is a drop-in replacement:\n\n```bash\nnpm install url-safe-string@latest\n```\n\nIf you need to support Node.js < 14, pin to v1.x:\n\n```bash\nnpm install url-safe-string@1\n```\n\n## Changelog\n\n### 2.0.0\n\n- Added automatic transliteration of accented/special characters to ASCII equivalents (enabled by default). Covers German (ä->ae, ö->oe, ü->ue, ß->ss), French, Spanish, Portuguese, Nordic, Polish, Czech, and Romanian characters. Can be disabled with `transliterate: false`. Closes [#2](https://github.com/a-r-d/url-safe-string/issues/2).\n- Added `transliterations` option for custom character mappings (e.g. `{ '&': 'and', '@': 'at' }`), merged on top of defaults\n- Added `trimResult` option (default `true`) to strip leading/trailing join strings from output\n- Added `UrlSafeString.generate()` static convenience method -- no constructor needed for default options\n- Added TypeScript type definitions (`index.d.ts`) -- fully typed options, instance, and constructor\n- Added ES Module support -- `import UrlSafeString from 'url-safe-string'` now works alongside `require()`\n- Added `exports` field for proper dual CJS/ESM package resolution\n- Added `files` field to keep the published package minimal\n- Minimum Node.js version bumped from 4 to 14\n- Switched test runner from Mocha to Vitest\n- Replaced Travis CI with GitHub Actions (testing Node 14, 16, 18, 20, 22)\n- Improved npm discoverability with expanded keywords and description\n- Updated README with ESM/TypeScript usage examples and options table\n\n### 1.1.0\n\n- Last release before the v2.0 modernization\n- Supports Node.js >= 4\n- CommonJS only (`require('url-safe-string')`)\n- No TypeScript definitions\n- If you need the pre-ES6 version, see v1.0.0\n\n### 1.0.0\n\n- Initial release with ES5 syntax\n\n## License\n\nISC\n","readmeFilename":"README.md"}