Merge commit from fork
This commit is contained in:
1 parent
d4e4c9669d
commit
b3e9b3351b
3 files changed
+24
-2
No files matched your search
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Sanitizes the URL from malicious payloads.
|
||||
* Prevents open redirects such as //example.com/path
|
||||
* and prevents XSS such as javascript:().
|
||||
* Returns / as a default or when unsafe.
|
||||
* @param url The URL to sanitize
|
||||
*/
|
||||
export const sanitizeRedirectionUrl = (url?: string) => {
|
||||
if (url && url.startsWith("/") && !url.startsWith("//")) {
|
||||
return url;
|
||||
} else {
|
||||
return '/'; // Safe default
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user