Skip to content
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

dot "." is legal in a URL but it is replaced with "-" #55

Closed
terchris opened this issue Dec 9, 2020 · 8 comments · Fixed by #70
Closed

dot "." is legal in a URL but it is replaced with "-" #55

terchris opened this issue Dec 9, 2020 · 8 comments · Fixed by #70
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@terchris
Copy link

terchris commented Dec 9, 2020

HI Sindre
I have been using your slugify and I find it very useful. So thank you for offering it.

I discovered that a url containing a dot is converted. Eg:
version3.1 is converted to version3-1

This created problems when I'm creating slugs for URLs like https://api.insightly.com/v3.1/Help

According to the spec of url written by Tim Berners-Lee back in 1994 it is legal to have a dot "." (punktum) in a url.
https://www.w3.org/Addressing/URL/url-spec.txt

Is there a way to instruct slugify to not convert "." to "-" ?

@sindresorhus
Copy link
Owner

There are lots of characters that are allowed in a URL that are replaced by a dash. That's how slugification usually works.

We could potentially add an option with an array of characters to preserve, but as a user, I think version3-1 is perfectly fine.

@GrosSacASac
Copy link

As I understands, slugify should work nice with filenames, and having a dot in the filename can change how it is opened by default

@Xendiadyon
Copy link

A setting with characters to preserve would be great!

@iffjey
Copy link

iffjey commented Aug 15, 2021

I also encountered this issue during migration of a blog. In a previous system we used «underscore» as valid part of slug. And now in Gatsby it's impossible to save previous structure/paths. Would be really awesome to see this improvement.

@iffjey
Copy link

iffjey commented Aug 25, 2021

@sindresorhus If you okay with a proposal to add an option to preserve some characters, I can make a PR

p.s. oh crap, just noticed that you're on a vacation, sry :)

@sindresorhus
Copy link
Owner

PR welcome. You can use 2aa5659 as an example of what's expected of the PR.

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Aug 25, 2021
@iffjey
Copy link

iffjey commented Aug 25, 2021

Also I noticed, that Gatsby uses v.1.x.x of slugify, so this change probably won't benefit me 😅. But I will try anyway. Thank you

@sailuna
Copy link

sailuna commented Oct 7, 2022

Hello @sindresorhus . Is it still perhaps possible to create a function that preserves a dot "." in the url? :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants