mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-26 13:26:22 +00:00
fix(path): properly path encode &
This commit is contained in:
parent
36e4cc41a9
commit
06ee73e006
2 changed files with 8 additions and 2 deletions
|
@ -106,8 +106,9 @@ describe("transforms", () => {
|
||||||
["test.mp4", "test.mp4"],
|
["test.mp4", "test.mp4"],
|
||||||
["note with spaces.md", "note-with-spaces"],
|
["note with spaces.md", "note-with-spaces"],
|
||||||
["notes.with.dots.md", "notes.with.dots"],
|
["notes.with.dots.md", "notes.with.dots"],
|
||||||
["test/special chars?.md", "test/special-chars-q"],
|
["test/special chars?.md", "test/special-chars"],
|
||||||
["test/special chars #3.md", "test/special-chars-3"],
|
["test/special chars #3.md", "test/special-chars-3"],
|
||||||
|
["cool/what about r&d?.md", "cool/what-about-r-and-d"],
|
||||||
],
|
],
|
||||||
path.slugifyFilePath,
|
path.slugifyFilePath,
|
||||||
path.isFilePath,
|
path.isFilePath,
|
||||||
|
|
|
@ -51,7 +51,12 @@ function sluggify(s: string): string {
|
||||||
return s
|
return s
|
||||||
.split("/")
|
.split("/")
|
||||||
.map((segment) =>
|
.map((segment) =>
|
||||||
segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q").replace(/#/g, ""),
|
segment
|
||||||
|
.replace(/\s/g, "-")
|
||||||
|
.replace(/&/g, "-and-")
|
||||||
|
.replace(/%/g, "-percent")
|
||||||
|
.replace(/\?/g, "")
|
||||||
|
.replace(/#/g, ""),
|
||||||
)
|
)
|
||||||
.join("/") // always use / as sep
|
.join("/") // always use / as sep
|
||||||
.replace(/\/$/, "")
|
.replace(/\/$/, "")
|
||||||
|
|
Loading…
Reference in a new issue