Fix location of removing dots
This commit is contained in:
@@ -30,14 +30,15 @@ export function createFilenameFromString(
|
||||
// Remove any leading or trailing hyphens or dots
|
||||
fileName = fileName.replaceAll(/^[.-]+|[.-]+$/g, "");
|
||||
|
||||
// Replace dots by hyphens if dots are not allowed
|
||||
if (removeDots) {
|
||||
fileName = fileName.replaceAll(/\./g, "-");
|
||||
}
|
||||
|
||||
// Remove any duplicate hyphens
|
||||
fileName = fileName.replaceAll(/-{2,}/g, "-");
|
||||
// Remove any duplicate dots
|
||||
fileName = fileName.replaceAll(/\.{2,}/g, ".");
|
||||
|
||||
if (removeDots) {
|
||||
fileName = fileName.replaceAll(/\./g, "-");
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ describe("createFilenameFromString", () => {
|
||||
filename: "unetworking-uwebsockets.js",
|
||||
filenameWithoutDots: "unetworking-uwebsockets-js",
|
||||
},
|
||||
{
|
||||
input: "github/.vscode-codeql",
|
||||
filename: "github-.vscode-codeql",
|
||||
filenameWithoutDots: "github-vscode-codeql",
|
||||
},
|
||||
];
|
||||
|
||||
test.each(testCases)(
|
||||
|
||||
Reference in New Issue
Block a user