@excofy/utils 2.6.3 → 2.6.4
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.cjs +6 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/src/helpers/string.ts +12 -0
package/dist/index.cjs
CHANGED
|
@@ -733,7 +733,12 @@ var generateCode = (length = 6, type = "alphanumeric") => {
|
|
|
733
733
|
|
|
734
734
|
// src/helpers/string.ts
|
|
735
735
|
var stringUtils = {
|
|
736
|
-
removeFileExtension: (fileName) => fileName.replace(/\.[^/.]+$/, "")
|
|
736
|
+
removeFileExtension: (fileName) => fileName.replace(/\.[^/.]+$/, ""),
|
|
737
|
+
normalizeName: (name) => {
|
|
738
|
+
let normalized = name;
|
|
739
|
+
normalized = normalized.toLowerCase().normalize("NFD").replace(/\p{M}/gu, "").replace(/[^a-z0-9 -]/g, "");
|
|
740
|
+
return normalized;
|
|
741
|
+
}
|
|
737
742
|
};
|
|
738
743
|
|
|
739
744
|
// src/errors/crypto/CryptoError.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -109,6 +109,7 @@ declare const generateCode: (length?: number, type?: "alphanumeric" | "numeric"
|
|
|
109
109
|
|
|
110
110
|
declare const stringUtils: {
|
|
111
111
|
removeFileExtension: (fileName: string) => string;
|
|
112
|
+
normalizeName: (name: string) => string;
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
interface IGenerateAccessToken {
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ declare const generateCode: (length?: number, type?: "alphanumeric" | "numeric"
|
|
|
109
109
|
|
|
110
110
|
declare const stringUtils: {
|
|
111
111
|
removeFileExtension: (fileName: string) => string;
|
|
112
|
+
normalizeName: (name: string) => string;
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
interface IGenerateAccessToken {
|
package/dist/index.js
CHANGED
|
@@ -694,7 +694,12 @@ var generateCode = (length = 6, type = "alphanumeric") => {
|
|
|
694
694
|
|
|
695
695
|
// src/helpers/string.ts
|
|
696
696
|
var stringUtils = {
|
|
697
|
-
removeFileExtension: (fileName) => fileName.replace(/\.[^/.]+$/, "")
|
|
697
|
+
removeFileExtension: (fileName) => fileName.replace(/\.[^/.]+$/, ""),
|
|
698
|
+
normalizeName: (name) => {
|
|
699
|
+
let normalized = name;
|
|
700
|
+
normalized = normalized.toLowerCase().normalize("NFD").replace(/\p{M}/gu, "").replace(/[^a-z0-9 -]/g, "");
|
|
701
|
+
return normalized;
|
|
702
|
+
}
|
|
698
703
|
};
|
|
699
704
|
|
|
700
705
|
// src/errors/crypto/CryptoError.ts
|
package/package.json
CHANGED
package/src/helpers/string.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export const stringUtils = {
|
|
2
2
|
removeFileExtension: (fileName: string): string =>
|
|
3
3
|
fileName.replace(/\.[^/.]+$/, ''),
|
|
4
|
+
|
|
5
|
+
normalizeName: (name: string): string => {
|
|
6
|
+
let normalized = name
|
|
7
|
+
|
|
8
|
+
normalized = normalized
|
|
9
|
+
.toLowerCase() // Convert the string to lowercase letters
|
|
10
|
+
.normalize("NFD") // The normalize() method returns the Unicode Normalization Form of a given string.
|
|
11
|
+
.replace(/\p{M}/gu, "") // Remove all previously normalized characters e.g. accents, umlauts etc.
|
|
12
|
+
.replace(/[^a-z0-9 -]/g, "") // Remove all characters that are not the given ones
|
|
13
|
+
|
|
14
|
+
return normalized
|
|
15
|
+
}
|
|
4
16
|
};
|