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

feat: handle korean as a valid file name component #3652

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/bruno-app/src/utils/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down