mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
feat: handle korean as a valid file name component
This commit is contained in:
parent
57d86eb118
commit
fcea2314bc
@ -70,16 +70,26 @@ export const safeParseXML = (str, options) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Remove any characters that are not alphanumeric, spaces, hyphens, or underscores
|
||||
export const normalizeFileName = (name) => {
|
||||
if (!name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const validChars = /[^\w\s-]/g;
|
||||
const formattedName = name.replace(validChars, '-');
|
||||
// alphanumerics, spaces, underscores, hyphens
|
||||
const baseValidExpression = '\\w\\s-';
|
||||
const additionalValidExpressions = [
|
||||
'ㄱ-ㅎ|ㅏ-ㅣ|가-힣', // Korean
|
||||
];
|
||||
|
||||
return formattedName;
|
||||
const validExpression = [
|
||||
baseValidExpression,
|
||||
...additionalValidExpressions,
|
||||
].join('|');
|
||||
|
||||
const invalidCharRegex = new RegExp(`[^${validExpression}]`, 'g')
|
||||
const normalizedFileName = name.replace(invalidCharRegex, '-');
|
||||
|
||||
return normalizedFileName;
|
||||
};
|
||||
|
||||
export const getContentType = (headers) => {
|
||||
|
Loading…
Reference in New Issue
Block a user