@ancon/wildcat-utils 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/string/index.d.ts +2 -0
- package/dist/string/index.js +8 -0
- package/dist/string/slugify.d.ts +1 -0
- package/dist/string/slugify.js +15 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.slugify = void 0;
|
|
7
|
+
const slugify_1 = __importDefault(require("./slugify"));
|
|
8
|
+
exports.slugify = slugify_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function slugify(str: string, locales?: string | string[]): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function slugify(str, locales) {
|
|
4
|
+
return str
|
|
5
|
+
.toLocaleLowerCase(locales)
|
|
6
|
+
.replace(/[åäæ]/g, 'a') // Replace å, ä and æ with a
|
|
7
|
+
.replace(/[öø]/g, 'o') // Replace ö and ø with o
|
|
8
|
+
.replace(/[é]/g, 'e') // Replace é with e
|
|
9
|
+
.replace(/\s+/g, '-') // Replace spaces with -
|
|
10
|
+
.replace(/[^\w-]+/g, '') // Remove all non-word chars
|
|
11
|
+
.replace(/--+/g, '-') // Replace multiple - with single -
|
|
12
|
+
.replace(/^-+/, '') // Trim - from start of text
|
|
13
|
+
.replace(/-+$/, ''); // Trim - from end of text
|
|
14
|
+
}
|
|
15
|
+
exports.default = slugify;
|