Skip to content

Commit ab19bba

Browse files
regularize all inputted page paths
1 parent 03f647c commit ab19bba

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

website/src/pages/edit.page.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ const NewPage = () => {
3131
const [isNew, setIsNew] = useState(true)
3232

3333
const formatPath = (path: string) => {
34-
return path.startsWith("/")
35-
? path
36-
: `/${path
37-
.toLowerCase()
38-
.replace(/ /g, "-")
39-
.replace(/[^a-z0-9-]/g, "")}`
34+
let regularizedPath = path
35+
.toLowerCase()
36+
.replace(/ /g, "-")
37+
.replace(/[^a-z0-9-]/g, "")
38+
return regularizedPath.startsWith("/")
39+
? regularizedPath
40+
: `/${regularizedPath}`
4041
}
4142

4243
const [{ data }, reexec] = usePageByPathQuery({

0 commit comments

Comments
 (0)