Comparing version 5.1.1 to 5.2.0
@@ -0,1 +1,8 @@ | ||
# [5.2.0](https://github.com/Trott/slug/compare/v5.1.1...v5.2.0) (2021-12-27) | ||
### Features | ||
* add ability to set default locale via setLocale() ([#269](https://github.com/Trott/slug/issues/269)) ([add368d](https://github.com/Trott/slug/commit/add368dbe5065f953d450f4f917fced42a08bf87)) | ||
## [5.1.1](https://github.com/Trott/slug/compare/v5.1.0...v5.1.1) (2021-12-13) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "slug", | ||
"description": "slugifies even utf-8 chars!", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"homepage": "https://github.com/Trott/slug", | ||
@@ -6,0 +6,0 @@ "author": "dodo (https://github.com/dodo)", |
@@ -31,2 +31,7 @@ # [slug](https://github.com/Trott/slug) | ||
// To reset modifications to slug.charmap, use slug.reset(): | ||
slug.reset() | ||
print(slug('I ♥ UNICODE')) | ||
// > i_unicode | ||
print(slug('Telephone-Number')) // lower case by default | ||
@@ -47,15 +52,20 @@ // > telephone-number | ||
print(slug('unicode ♥ is ☢')) | ||
// > unicode-love-is | ||
// To set the default locale: | ||
slug.setLocale('bg') | ||
print(slug('маленький подъезд')) | ||
// > malenykiy-podaezd | ||
print(slug('unicode is ☢')) | ||
// > unicode-is | ||
slug.extend({'☢': 'radioactive'}) | ||
print(slug('unicode ♥ is ☢')) | ||
// > unicode-love-is-radioactive | ||
// > unicode-is-radioactive | ||
// slug.extend() modifies the default charmap for the entire process. | ||
// If you need to reset charmap and multicharmap, use slug.reset(): | ||
// If you need to reset charmap, multicharmap, and the default locale, use slug.reset(): | ||
slug.reset() | ||
print(slug('unicode ♥ is ☢')) | ||
// > unicode-love-is | ||
// > unicode-is | ||
@@ -62,0 +72,0 @@ // Custom removal of characters from resulting slug. Let's say that we want to |
@@ -148,2 +148,4 @@ /* global btoa */ | ||
let defaultLocale = {} | ||
function slugify (string, opts) { | ||
@@ -162,3 +164,3 @@ if (typeof string !== 'string') { | ||
} | ||
const localeMap = locales[opts.locale] || {} | ||
const localeMap = locales[opts.locale] || defaultLocale | ||
@@ -897,2 +899,3 @@ let lengths = [] | ||
slug.defaults.modes.rfc3986.multicharmap = slug.defaults.modes.pretty.multicharmap = slug.multicharmap = slug.defaults.multicharmap = Object.assign({}, initialMulticharmap) | ||
defaultLocale = '' | ||
} | ||
@@ -915,2 +918,6 @@ | ||
slug.setLocale = function (locale) { | ||
defaultLocale = locales[locale] || {} | ||
} | ||
/* global define */ | ||
@@ -917,0 +924,0 @@ // Be compatible with different module systems |
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
31357
899
104