You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
Current behavior
I am trying to slugify a city name: Malmö {{ 'Malmö' | slugify }} = malm
Expected behavior
I would expect it to replace the ö for an o {{ 'Malmö' | slugify }} = malmo
Minimal reproduction of the problem with instructions
plnkr isn't loading right now, but simple to replicate. I have previously been using a function which does the replacement for you:
slugify(text) {
if (text) {
const specialChars = {'à': 'a', 'ä': 'a', 'á': 'a', 'â': 'a', 'æ': 'a', 'å': 'a', 'ë': 'e', 'è': 'e', 'é': 'e',
'ê': 'e', 'î': 'i', 'ï': 'i', 'ì': 'i', 'í': 'i', 'ò': 'o', 'ó': 'o', 'ö': 'o', 'ô': 'o', 'ø': 'o', 'ù': 'o',
'ú': 'u', 'ü': 'u', 'û': 'u', 'ñ': 'n', 'ç': 'c', 'ß': 's', 'ÿ': 'y', 'œ': 'o', 'ŕ': 'r', 'ś': 's', 'ń': 'n',
'ṕ': 'p', 'ẃ': 'w', 'ǵ': 'g', 'ǹ': 'n', 'ḿ': 'm', 'ǘ': 'u', 'ẍ': 'x', 'ź': 'z', 'ḧ': 'h', '·': '-', '/': '-',
'_': '-', ', ': '-', ': ': '-', ';': '-'};
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/./g, (target, index, str) => specialChars[target] || target) // Replace special characters using the hash map
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
} else {
return false;
}
}
What is the motivation / use case for changing the behavior?
nicer slugs for urls, easier to read as they are closer to the originals
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current behavior
I am trying to slugify a city name: Malmö
{{ 'Malmö' | slugify }} = malm
Expected behavior
I would expect it to replace the ö for an o
{{ 'Malmö' | slugify }} = malmo
Minimal reproduction of the problem with instructions
plnkr isn't loading right now, but simple to replicate. I have previously been using a function which does the replacement for you:
What is the motivation / use case for changing the behavior?
nicer slugs for urls, easier to read as they are closer to the originals
The text was updated successfully, but these errors were encountered: