mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-22 12:56:37 +00:00
✨ support pathname in logo URL in branding page
This commit is contained in:
16
src/lib/validateLocalPath.ts
Normal file
16
src/lib/validateLocalPath.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export function validateLocalPath(value: string) {
|
||||
try {
|
||||
const url = new URL("https://pangoling.net" + value);
|
||||
if (
|
||||
url.pathname !== value ||
|
||||
value.includes("..") ||
|
||||
value.includes("*")
|
||||
) {
|
||||
throw new Error("Invalid Path");
|
||||
}
|
||||
} catch {
|
||||
throw new Error(
|
||||
"should be a valid pathname starting with `/` and not containing query parameters, `..` or `*`"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user