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

Factorize and enhance sanitizeFilename method #1448

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

pgiraud
Copy link
Contributor

@pgiraud pgiraud commented Sep 21, 2016

With this pull request the sanitizeFilename is declared only once.
Also the regexp has been improved.

name.replace(/\s+/gi, '_')
name.replace(/[^a-zA-Z0-9\-]/gi, '')

is changed to

name.replace(/\s+/g, '_')
name.replace(/[^a-z0-9\-\_]/gi, '')

First regexp doesn't need to be case insensitive.
Underscores are not removed any more in the second one.
Also, because the second one is case insensitive, we don't need to search for "A-Z", "a-z" is already removing upper cased characters.

Please review.

Copy link
Contributor

@rmichaelis rmichaelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pgiraud pgiraud merged commit 66a62e6 into Geoportail-Luxembourg:master Sep 21, 2016
@pgiraud pgiraud deleted the sanitize_factorized branch September 21, 2016 14:57
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

Successfully merging this pull request may close these issues.

2 participants