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

Make patternSlug customizable #54

Closed
apiel opened this issue Oct 22, 2020 · 3 comments
Closed

Make patternSlug customizable #54

apiel opened this issue Oct 22, 2020 · 3 comments

Comments

@apiel
Copy link

apiel commented Oct 22, 2020

Hello,

Would it be possible to make the patternSlug configurable, so for example if we want to have # in our slug, we could do something like slugify('foo#bar hello$123', {patternSlug: /[^a-zA-Z#\d]+/g}); to get foo#bar-hello-123.

Would be really amazing feature :-)

@sindresorhus
Copy link
Owner

Why do you need to ignore #? What's the use-case? Then it's technically no longer a slug.

@apiel
Copy link
Author

apiel commented Oct 22, 2020

Depends for which purpose we use the slug. We use it in our db to create some tags.

@sindresorhus
Copy link
Owner

I don't want to expose the pattern slug regex, as it's an implementation detail, and this would lock us into that way of doing it forever. I would be open to an option to preserve a set of given characters, but I think in your case, it would be simpler for you to just split it on #, run the parts through slugify, and then join again.

@apiel apiel closed this as completed Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants