{"id":13451907,"url":"https://github.com/Trott/slug","last_synced_at":"2025-03-23T19:33:10.169Z","repository":{"id":37175755,"uuid":"154614115","full_name":"Trott/slug","owner":"Trott","description":"slugifies even utf-8 chars!","archived":false,"fork":false,"pushed_at":"2024-10-28T13:14:55.000Z","size":2380,"stargazers_count":340,"open_issues_count":7,"forks_count":33,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T15:12:44.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Trott.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-25T05:19:41.000Z","updated_at":"2024-10-28T08:57:51.000Z","dependencies_parsed_at":"2024-01-16T22:41:22.024Z","dependency_job_id":"5263b46d-0af0-42e3-ace1-b076e14d7327","html_url":"https://github.com/Trott/slug","commit_stats":{"total_commits":589,"total_committers":33,"mean_commits":"17.848484848484848","dds":0.6570458404074703,"last_synced_commit":"b740c0de46c7783269bedbffa8e3aedeaadca0ce"},"previous_names":["trott/node-slug"],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trott%2Fslug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trott%2Fslug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trott%2Fslug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trott%2Fslug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Trott","download_url":"https://codeload.github.com/Trott/slug/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801604,"owners_count":20350105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:01:06.611Z","updated_at":"2025-03-23T19:33:10.148Z","avatar_url":"https://github.com/Trott.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# [slug](https://github.com/Trott/slug)\n\nSlugifies strings, even when they contain Unicode.\n\nMake strings URL-safe.\n\n- Respects [RFC 3986](https://tools.ietf.org/html/rfc3986)\n- No dependencies\n- Works in the browser or in Node.js\n\n```\nnpm install slug\n```\n\nIf you are using TypeScript you can install the accompanying types\n\n```\nnpm install --save-dev @types/slug\n```\n\n## Example\n\n```javascript\nimport slug from 'slug'\nvar print = console.log.bind(console, '\u003e')\n\nprint(slug('i love unicode'))\n// \u003e i-love-unicode\n\nprint(slug('i love unicode', '_')) // If you prefer something else than `-` as separator\n// \u003e i_love_unicode\n\nslug.charmap['♥'] = 'freaking love' // change default charmap or use option {charmap:{…}} as 2. argument\nprint(slug('I ♥ UNICODE'))\n// \u003e i-freaking-love-unicode\n\n// To reset modifications to slug.charmap, use slug.reset():\nslug.reset()\nprint(slug('I ♥ UNICODE'))\n// \u003e i-unicode\n\nprint(slug('Telephone-Number')) // lower case by default\n// \u003e telephone-number\n\nprint(slug('Telephone-Number', {lower: false})) // If you want to preserve case\n// \u003e Telephone-Number\n\n// We try to provide sensible defaults.\n// So Cyrillic text will be transliterated as if it were Russian:\nprint(slug('маленький подъезд'))\n// \u003e malenkij-poduezd\n\n// But maybe you know it's Bulgarian:\nprint(slug('маленький подъезд', { locale: 'bg' }))\n// \u003e malenykiy-podaezd\n\n// To set the default locale:\nslug.setLocale('bg')\nprint(slug('маленький подъезд'))\n// \u003e malenykiy-podaezd\n\nprint(slug('unicode is ☢'))\n// \u003e unicode-is\n\nslug.extend({'☢': 'radioactive'})\nprint(slug('unicode ♥ is ☢'))\n// \u003e unicode-is-radioactive\n\n// slug.extend() modifies the default charmap for the entire process.\n// If you need to reset charmap, multicharmap, and the default locale, use slug.reset():\n\nslug.reset()\nprint(slug('unicode ♥ is ☢'))\n// \u003e unicode-is\n\n// Custom removal of characters from resulting slug. Let's say that we want to\n// remove all numbers for some reason.\nprint(slug('one 1 two 2 three 3'))\n// \u003e one-1-two-2-three-3\nprint(slug('one 1 two 2 three 3', { remove: /[0-9]/g }))\n// \u003e one-two-three\n```\n\n## options\n\n```javascript\n// options is either object or replacement (sets options.replacement)\nslug('string', [{options} || 'replacement']);\n```\n\n```javascript\nslug.defaults.mode ='pretty';\nslug.defaults.modes['rfc3986'] = {\n    replacement: '-',      // replace spaces with replacement\n    remove: null,          // (optional) regex to remove characters\n    lower: true,           // result in lower case\n    charmap: slug.charmap, // replace special characters\n    multicharmap: slug.multicharmap, // replace multiple code unit characters\n    trim: true,             // trim leading and trailing replacement chars\n    fallback: true          // use base64 to generate slug for empty results\n};\nslug.defaults.modes['pretty'] = {\n    replacement: '-',\n    remove: null,\n    lower: false,\n    charmap: slug.charmap,\n    multicharmap: slug.multicharmap,\n    trim: true,\n    fallback: true\n};\n```\n\n## Differences between `slug` and `slugify` packages\n\nHere are some key differences between this package and [`slugify`](https://github.com/simov/slugify).\n\n- **Stability:** `slug` is ESM-only.  \n  `slugify` supports CommonJS and ESM.\n- **Defaults:** `slug` has the `lower` option enabled by default, lowercasing all slugs\n  (`'On SALE'` becomes `'on-sale'`).  \n  `slugify` has the `lower` option disabled by default (`'On SALE'` becomes `'On-SALE'`).\n- **Symbols:** `slug` removes unrecognized symbols (`'$100'` becomes `'100'`, `'\u003c5'` becomes `'5'`, etc.).  \n  `slugify` maps them to words (`'$100'` becomes `'dollar100'`, `'\u003c5'` becomes `'less5'`, etc.).\n- **Empty Output:** `slug` will return a short, predictable hash (`'   '` becomes `'icag'` and `'🎉'` becomes `'8joiq'`).  \n  `slugify` will return an empty string (`'   '` and `'🎉'` become `''`).\n\n## Playground\n\nA web playground is available at https://trott.github.io/slug/.\n\nThere is also a CLI tool available via `npx slug`. It doesn't allow you to\nspecify options, so it's utility is minimal.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTrott%2Fslug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTrott%2Fslug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTrott%2Fslug/lists"}