Comparing version 3.0.2 to 3.0.3
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.urlSlug = factory()); | ||
}(this, (function () { 'use strict'; | ||
})(this, (function () { 'use strict'; | ||
@@ -215,2 +215,2 @@ const INVALID_SEPARATOR = /[^-._~!$&'()*+,;=]/; | ||
}))); | ||
})); |
@@ -187,3 +187,2 @@ const LOWERCASE_TRANSFORMER = function (fragments, separator) { | ||
export default convert; | ||
export { LOWERCASE_TRANSFORMER, SENTENCECASE_TRANSFORMER, TITLECASE_TRANSFORMER, UPPERCASE_TRANSFORMER, convert, revert }; | ||
export { LOWERCASE_TRANSFORMER, SENTENCECASE_TRANSFORMER, TITLECASE_TRANSFORMER, UPPERCASE_TRANSFORMER, convert, convert as default, revert }; |
{ | ||
"name": "url-slug", | ||
"version": "3.0.2", | ||
"description": "Slug generator with less than 1 KB and no dependencies, RFC 3986 compliant.", | ||
"version": "3.0.3", | ||
"description": "Slug generator with less than 1 KB and no dependencies, RFC 3986 compliant", | ||
"main": "dist/index.js", | ||
@@ -16,7 +16,7 @@ "module": "lib/index.js", | ||
"devDependencies": { | ||
"@rollup/plugin-replace": "^2.3.4", | ||
"@rollup/plugin-replace": "^3.0.0", | ||
"cross-env": "^7.0.3", | ||
"jest": "^26.6.3", | ||
"jest": "^27.2.1", | ||
"jest-esm-transformer": "^1.0.0", | ||
"rollup": "^2.36.0", | ||
"rollup": "^2.57.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
@@ -23,0 +23,0 @@ "standard": "*" |
@@ -1,6 +0,8 @@ | ||
# url-slug [![build status](https://img.shields.io/travis/stldo/url-slug/master)](https://travis-ci.org/stldo/url-slug) [![npm](https://img.shields.io/npm/v/url-slug)](https://www.npmjs.com/package/url-slug) | ||
# url-slug [![Build status][1]][2] [![npm][3]][4] [![minzipped size][5]][6] | ||
- __Less than 1kB__ minified and gzipped; | ||
- Uses default JavaScript APIs, __no dependencies__; | ||
- __RFC 3986__ compliant, compatible with URL hosts, paths, queries and fragments; | ||
- __SEO__ friendly; | ||
- __RFC 3986__ compliant, compatible with URL hosts, paths, queries and | ||
fragments; | ||
- Supports __custom dictionaries__ to replace characters; | ||
@@ -39,4 +41,4 @@ - Easily __revert slugs__. | ||
| camelCase | Split on camel case occurrences | `true` | | ||
| dictionary | [Chars to be replaced](#dictionary-option-considerations) | `{}` | | ||
| separator | [Character or string](#accepted-separator-characters) used to separate the slug fragments | `'-'` | | ||
| dictionary | [Chars to be replaced][7] | `{}` | | ||
| separator | [Character or string][8] used to separate the slug fragments | `'-'` | | ||
| transformer | A built-in transformer or a custom function (`false` to keep the string unchanged) | `LOWERCASE_TRANSFORMER` | | ||
@@ -85,3 +87,3 @@ | ||
| camelCase | Split on camel case occurrences | `false` | | ||
| separator | [Character or string](#accepted-separator-characters) to split the slug (`null` accounts to automatic splitting) | `null` | | ||
| separator | [Character or string][8] to split the slug (`null` accounts to automatic splitting) | `null` | | ||
| transformer | A built-in transformer or a custom function (`false` to keep the string unchanged) | `false` | | ||
@@ -108,3 +110,8 @@ | ||
Custom transformers are expressed by a function that receives two arguments, `fragments`, an array with matching words from a sentence or a slug, and `separator`, which will be the separator string set in `convert()` options. When `revert()` calls the transformer, the `separator` argument will always be a space character (`' '`) — the `separator` option will be used to split the slug. Transformers should always return a string. | ||
Custom transformers are expressed by a function that receives two arguments, | ||
`fragments`, an array with matching words from a sentence or a slug, and | ||
`separator`, which will be the separator string set in `convert()` options. When | ||
`revert()` calls the transformer, the `separator` argument will always be a | ||
space character (`' '`) — the `separator` option will be used to split the slug. | ||
Transformers should always return a string. | ||
@@ -150,9 +157,15 @@ #### Examples | ||
Any character defined as _unreserved_ or _sub-delims_ in RFC 3986, or an empty string, can be used as `separator`. When the `separator` is an empty string, the `revert()` method will split the slug only on camel case occurrences — if `camelCase` option is set to `true`, otherwise it will return an untouched string. The following characters are valid: | ||
Any character defined as _unreserved_ or _sub-delims_ in RFC 3986, or an empty | ||
string, can be used as `separator`. When the `separator` is an empty string, the | ||
`revert()` method will split the slug only on camel case occurrences — if | ||
`camelCase` option is set to `true`, otherwise it will return an untouched | ||
string. The following characters are valid: | ||
`-`, `.`, `_`, `~`, `^`, `-`, `.`, `_`, `~`, `!`, `$`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `;` or `=` | ||
`-`, `.`, `_`, `~`, `^`, `-`, `.`, `_`, `~`, `!`, `$`, `&`, `'`, `(`, `)`, `*`, | ||
`+`, `,`, `;` or `=` | ||
### `dictionary` option considerations | ||
It must be an object, with keys set as single characters and values as strings of any length: | ||
It must be an object, with keys set as single characters and values as strings | ||
of any length: | ||
@@ -173,3 +186,4 @@ ```js | ||
To add separators before or after a specific character, add a space before or after the dictionary definition: | ||
To add separators before or after a specific character, add a space before or | ||
after the dictionary definition: | ||
@@ -210,10 +224,21 @@ ```js | ||
### Polyfilling | ||
### Polyfill | ||
This module uses `String.prototype.normalize()` to convert strings to slugs. If | ||
you need to support old browsers (e.g. Internet Explorer), you can use a | ||
polyfill like [unorm](https://github.com/walling/unorm). | ||
polyfill like [unorm][9]. | ||
## License | ||
[The MIT License](./LICENSE) | ||
[The MIT License][license] | ||
[1]: https://img.shields.io/github/workflow/status/stldo/url-slug/Node.js%20Test | ||
[2]: https://github.com/stldo/url-slug/actions/workflows/test.js.yml | ||
[3]: https://img.shields.io/npm/v/url-slug | ||
[4]: https://www.npmjs.com/package/url-slug | ||
[5]: https://img.shields.io/bundlephobia/minzip/url-slug | ||
[6]: https://bundlephobia.com/package/url-slug | ||
[7]: #dictionary-option-considerations | ||
[8]: #accepted-separator-characters | ||
[9]: https://github.com/walling/unorm | ||
[license]: ./LICENSE |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21388
239
354