“It’s only work if somebody makes you do it.” • craft code • creative ideas • cutting edge • author • senior front end architect • professional scuba diver • adventures above and below the sea level
Location
Germany
Work
Senior Front End Architect, Full Stack Engineer, Creative Technologist and Scuba Diving Professional
What are your concerns about the code? Unicode characters can be part of an url, we're just removing some "unnecessary" characters to shorten the string (:;…?!) and replacing the whitespace with '-' to mach the conventions.
What would be your suggestion to enhance the code?
When you copy a URL containing Unicode characters from the address bar and then, for example, paste it into a chat message - all the unicode characters are now encoded - ruining your nice 'readable' URL.
A lot of the good slug libraries cope with this to varying extents by trying to keep the slug to the standard latin alphabet. Obviously this makes the libraries quite complex as simple character substitutions are not enough when working with languages that use entirely different glyphs (e.g Thai - สวัสดี) - transliteration is required.
“It’s only work if somebody makes you do it.” • craft code • creative ideas • cutting edge • author • senior front end architect • professional scuba diver • adventures above and below the sea level
Location
Germany
Work
Senior Front End Architect, Full Stack Engineer, Creative Technologist and Scuba Diving Professional
Well, a full fledged library is beyond the scope of "these one line functions" :D I'll add a disclaimer that it should be used with the standard latin alphabet.
Thank you for your time,
Martin
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Jon,
thank you for the time to comment.
What are your concerns about the code? Unicode characters can be part of an url, we're just removing some "unnecessary" characters to shorten the string (:;…?!) and replacing the whitespace with '-' to mach the conventions.
What would be your suggestion to enhance the code?
Cheers!
When you copy a URL containing Unicode characters from the address bar and then, for example, paste it into a chat message - all the unicode characters are now encoded - ruining your nice 'readable' URL.
A lot of the good slug libraries cope with this to varying extents by trying to keep the slug to the standard latin alphabet. Obviously this makes the libraries quite complex as simple character substitutions are not enough when working with languages that use entirely different glyphs (e.g Thai - สวัสดี) - transliteration is required.
Well, a full fledged library is beyond the scope of "these one line functions" :D I'll add a disclaimer that it should be used with the standard latin alphabet.
Thank you for your time,
Martin