-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby): migrate normalize-page-path to typescript (#22188)
- Loading branch information
1 parent
4404af1
commit 306cadd
Showing
3 changed files
with
31 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This is a duplicate of the runtime util | ||
// file cache-dir/normalize-page-path.js | ||
// While still a duplicate, this one is | ||
// rewritten in typescript | ||
export function normalizePagePath(path: string): string { | ||
if (path === undefined) { | ||
return path | ||
} | ||
if (path === `/`) { | ||
return `/` | ||
} | ||
if (path.charAt(path.length - 1) === `/`) { | ||
return path.slice(0, -1) | ||
} | ||
return path | ||
} | ||
|
||
export function denormalizePagePath(path: string): string { | ||
if (path === undefined) { | ||
return path | ||
} | ||
if (path === `/`) { | ||
return `/` | ||
} | ||
if (path.charAt(path.length - 1) !== `/`) { | ||
return path + `/` | ||
} | ||
return path | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters