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

Option to avoid removing repeated replacement #10

Open
alexander-akait opened this issue Jul 17, 2019 · 7 comments
Open

Option to avoid removing repeated replacement #10

alexander-akait opened this issue Jul 17, 2019 · 7 comments

Comments

@alexander-akait
Copy link

alexander-akait commented Jul 17, 2019

Usage:

const filenamofy = require('filenamify');

const safeFilename = filenamify('/path/to/file---name.ext', { replacement: '-' });

Now:
/path/to/file---name.ext -> path-to-file-name.ext

Feature request (maybe keepRepeat: true or better name):
/path/to/file---name.ext -> path-to-file---name.ext

@alexander-akait alexander-akait changed the title option to avoid removing repeated characters option to avoid removing repeated replacement Jul 17, 2019
@sindresorhus
Copy link
Owner

What's the use-case? I don't really see any good reason to preserve duplicate replacement characters like that.

@alexander-akait
Copy link
Author

@sindresorhus create css classes based on filesystem path, useful for css-loader, we already have same logic inside

@sindresorhus
Copy link
Owner

Alright. PR welcome.

Some name ideas:

  • condenseReplacements
  • preserveRepeatedReplacements
  • removeRepeatedReplacements

@sindresorhus sindresorhus changed the title option to avoid removing repeated replacement Option to avoid removing repeated replacement Feb 14, 2020
@GeorgeGkas
Copy link

@sindresorhus the replacement is done at filenamify.js#L30 using the tream-repeat library. We should implement the change in that library first I believe. I will open an issue and link it with this one.

@GeorgeGkas
Copy link

It seems that I missunderstood the question. I though we wanted to replace all the occurances of repeated characters, except a specific one. I'm closing the issue on tream-repeat repo.

@orsett0
Copy link
Contributor

orsett0 commented Dec 27, 2022

Is there any particular reason why #18 has been refused? I have a similar fix for this issue and was wondering if it would be welcomed.

@orsett0
Copy link
Contributor

orsett0 commented Apr 26, 2023

This was fixed in 7d4846f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants