Skip to content

Commit

Permalink
chore: use path.sep instead of forward slash
Browse files Browse the repository at this point in the history
  • Loading branch information
svedova committed Oct 13, 2023
1 parent 2d55c24 commit 3193008
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/filesys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const parseFileName = (

// /users/[id]/index.js => /users/:id
export const fileToRoute = (file: string): string => {
const fileName = file.split("/").pop()?.split(".")[0];
const fileName = file.split(path.sep).pop()?.split(".")[0];
let normalized = file.replace(/\[([a-zA-Z0-9_\.:-]*)\]/g, ":$1");

if (fileName === "index") {
Expand All @@ -76,7 +76,7 @@ export const fileToRoute = (file: string): string => {
normalized = normalized.split(".")[0];
}

return path.join("/", normalized);
return path.join(path.sep, normalized);
};

export const matchPath = (
Expand All @@ -89,7 +89,7 @@ export const matchPath = (
for (const file of files) {
const parsed = parseFileName(file.name);

if (file.name.startsWith("_") || file.rel.indexOf("/_") > -1) {
if (file.name.startsWith("_") || file.rel.indexOf(`${path.sep}_`) > -1) {
continue;
}

Expand Down

0 comments on commit 3193008

Please sign in to comment.