Skip to content

Commit af32dbe

Browse files
committed
perf: use slice instead of replace when joining path
1 parent 4a8b167 commit af32dbe

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/api/functions/join-path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function joinPathWithBasePath(filename: string, directoryPath: string) {
99
function joinPathWithRelativePath(root: string, options: Options) {
1010
return function (filename: string, directoryPath: string) {
1111
const sameRoot = directoryPath.startsWith(root);
12-
if (sameRoot) return directoryPath.replace(root, "") + filename;
12+
if (sameRoot) return directoryPath.slice(root.length) + filename;
1313
else
1414
return (
1515
convertSlashes(relative(root, directoryPath), options.pathSeparator) +

0 commit comments

Comments
 (0)