Skip to content

Commit

Permalink
feat: use unidecode to create filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
roedoejet committed Apr 2, 2024
1 parent 0714343 commit dfa34c5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
packages/ngx-web-component/**/generated
dist
www
.nx
.python-version
31 changes: 30 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/studio-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@angular/localize": "^15.2.4",
"@types/dom-mediacapture-record": "^1.0.15",
"@types/jasmine": "~4.0.0",
"@types/unidecode": "^0.1.3",
"jasmine-core": "~4.1.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
Expand Down Expand Up @@ -54,6 +55,7 @@
"soundswallower": "^0.6.3",
"standardized-audio-context": "^25.3.41",
"tslib": "^2.3.0",
"unidecode": "^1.0.1",
"zone.js": "^0.11.8"
},
"singleFileBundleVersion": "1.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/studio-web/src/app/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unidecode from "unidecode";

export const slugify = (str: string, character_limit: number = 0) => {
// Adapted from https://byby.dev/js-slugify-string
// Character limit of 0 (default) means there is no limit
const slug = String(str)
const slug = String(unidecode(str))
.normalize("NFC") // split accented characters into their base characters and diacritical marks
.replace(/[\u0300-\u036f]/g, "") // remove all the accents, which happen to be all in the \u03xx UNICODE block.
.trim() // trim leading or trailing whitespace
.toLowerCase() // convert to lowercase
.replace(/[^a-z0-9 -]/g, "") // remove non-alphanumeric characters
.replace(/\s+/g, "-") // replace spaces with hyphens
.replace(/-+/g, "-"); // remove consecutive hyphens

Expand Down

0 comments on commit dfa34c5

Please sign in to comment.