sindresorhus / filenamify

Convert a string to a valid safe filename
MIT License
490 stars 26 forks source link

Add `maxLength` option #9

Closed e-cloud closed 5 years ago

e-cloud commented 5 years ago

it's too limited to has only hardcoded MAX_FILENAME_LENGTH.

sindresorhus commented 5 years ago

Duplicate of https://github.com/sindresorhus/filenamify/issues/5

What's your use-case for needing more than 100 characters?

scott-ho commented 5 years ago

That depends on requirement. For one case, if someone need to log something into the file based on a java package name, it could be very long. 'xxxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxxx.xxxxxxxxxxxxxx.xxxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxxx.xxxxxxxxxxx.xxxxxxxxxx.xxxClass'.

For another, وزير الخارجية النمساوي: الوضع فى ليبيا "لا يزال بالغ السكك الحديدية في is a news title of Arab language.

I don't recommend hardcoding the constraints

sindresorhus commented 5 years ago

@scott-ho Alright

sindresorhus commented 5 years ago

@e-cloud I think the option should be named maxLength. And it needs a test.

sindresorhus commented 5 years ago

think the option should be named maxLength.

You didn't update all the places, the PR title included.

sindresorhus commented 5 years ago

Still not. Please look at the diff.