Created
December 30, 2018 01:32
-
-
Save morficus/75298908c356b0b1871cf16f9d9a4be0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a string with all S3 unsafe characters replaced with a dash (-) | |
* @param dirtyFileName | |
* @returns {*} | |
*/ | |
export default function(dirtyFileName) { | |
// handle any special characters that might be in the file name | |
// ref: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-key-guidelines | |
return dirtyFileName.replace(/[&$@=;:+,?^{}%`\]">~<#|]/g, '-') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment