Forward slash is valid url character but removed
See original GitHub issueSlugify is designed to support valid url characters. However if I pass in a forward slash:
slugify(`Something/Another thing`, { lower: true })
The result is:
somethinganother-thing
Where I would expect:
something/another-thing
This can of course be mitigated by changing the remove RegEx adding \/
:
console.log(slugify(`Something/Another thing`, { lower: true, remove: /[^\w\s$*_+~.()'"!\-:@\/]+/g }));
But this is not a very elegant solution. Ideally there would be an ignore/exclude character feature?
console.log(slugify(`Something/Another thing`, { lower: true, exclude: '/' }));
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (3 by maintainers)
Top Results From Across the Web
urlencoded Forward slash is breaking URL - Stack Overflow
I am using urlencode() while preparing the search URL and urldecode() while reading the search URL. Problem. Only the forward slash character is...
Read more >Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >regex last slash in url - Ristorante L'Attracco.
If your REGEX includes that character at the end, then a visit to the same URL but without the forward-slash wouldn't match. 4:...
Read more >URL encoding slash character ('/') and Apache web servers
Hi, I'm facing a problem with IIIF Image API 1.1 (it should be the same with API 2.0 though). I'm using : -...
Read more >What is a trailing slash? - Ryte Wiki
This should be taken into account mostly in cases where websites can be accessed through a URL with a different number of trailing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is perhaps more maintainable and understandable than passing in a
remove
regular expression.This is probably an over-engineered and inelegant solution, but I can’t tell so here it is anyway:
It would be a breaking change, but perhaps the
strict
option can be deprecated in favor of amode
setting that affects the defaults of things like theremove
regex.slugify
can ship with astrict
mode andloose
(orsloppy
or whatever you want to call it) mode, but people could add their own and perhaps even ship them as separate packages, effectively being a plugin: