@symbo.ls/utils 2.11.74 → 2.11.84

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +6 -2
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "2.11.74",
3
+ "version": "2.11.84",
4
4
  "main": "src/index.js",
5
5
  "author": "symbo.ls",
6
6
  "license": "ISC",
7
7
  "dependencies": {
8
8
  "@domql/utils": "latest"
9
9
  },
10
- "gitHead": "e5b1525de823174b2978cb9cda682b31f5cf87e8"
10
+ "gitHead": "51cf490aa9b1d763ed5befb62de7412b44b28061"
11
11
  }
package/src/index.js CHANGED
@@ -29,8 +29,12 @@ export const toTitleCase = str => str.replace(
29
29
  )
30
30
 
31
31
  export const toDashCase = val => val
32
- .replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
33
- .replace('.', '-')
32
+ .replace(/[^a-zA-Z0-9]/g, ' ') // Replace non-alphanumeric characters with spaces
33
+ .trim() // Remove leading and trailing spaces
34
+ .toLowerCase() // Convert to lowercase
35
+ .replace(/\s+/g, '-') // Replace spaces with dashes
36
+ .replace(/-+/g, '-') // Replace consecutive dashes with a single dash
37
+ .replace(/^-|-$/g, '') // Remove leading and trailing dashes
34
38
 
35
39
  export const toDescriptionCase = str => {
36
40
  const result = str.replace(/([A-Z])/g, ' $1')