Skip to content

Commit

Permalink
update validate
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Oct 16, 2023
1 parent 76db549 commit 86346f8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils/redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const validateRedirectURL = (
) => {
try {
if (!url || url.endsWith('.js')) throw new Error()
if (allowRelativePath && url.startsWith('/')) return url
const newUrl = new URL(url) // valid url
const newUrl = allowRelativePath && url.startsWith('/') ? new URL(`${window.location.origin}${url}`) : new URL(url)
if (
newUrl.pathname.endsWith('.js') ||
!['https:', 'http:'].includes(newUrl.protocol) ||
Expand Down

0 comments on commit 86346f8

Please sign in to comment.