-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cyrillic character in url causing encoding issues #172
Comments
I think another way to solve this is by extending slugify with your own translation of the Or maybe add it as a new locale in this module. As for the reason why |
Yes, if it's set to something else like |
I'm a little confused. I'm unable to repro the issue here, unless I'm misunderstanding. Maybe you're using an option that isn't the default somewhere? When I use the latest version of slugify, it removes the character. const slug = require('slug')
const slugify = require('slugify')
console.log(`SLUG "${slug('ь')}"`)
console.log(`SLUGIFY "${slugify('ь')}"`)
console.log(`SLUG "${slug('aь')}"`)
console.log(`SLUGIFY "${slugify('aь')}"`) Output:
slugify removes the character in both cases. slug does too but takes a different approach if the resulting slug is an empty string in its entirety. It generates a base64 encoding of the string as a slug. This way, you at least get something useable (if not ideal) if you use many strings consisting entirely of characters that are discarded. |
Also note that using |
Actually you are correct, @Trott, I was not able to reproduce that either. I thought I know about the issue because I remember someone reporting it in the past. @emoutisheva can you provide a sample that reproduces the issue? I tried with |
Yes, that is because |
Decided to add the locale. Thank you for your suggestions and time. |
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
slugify@1.6.5
for the project I'm working on.We use it to convert translations from other languages to english for url slugs for example : /anglijskaya-premьer-liga/
The character
ь
is mapped to an empty string in your charmap.json and it does not get converted or removed:var appendChar = locale[ch] || charMap[ch] || ch;
resulted invar appendChar = undefined || "" || ь.
This however was causing some encoding issues resulting in a redirect loop and not being able to open the urls. Changing the || to ?? will remove the character.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: