Hooks
This commit is contained in:
12
app/utils/isInternalUrl.js
Normal file
12
app/utils/isInternalUrl.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// @flow
|
||||
export default function isInternalUrl(href: string) {
|
||||
if (href[0] === '/') return true;
|
||||
|
||||
try {
|
||||
const outline = new URL(BASE_URL);
|
||||
const parsed = new URL(href);
|
||||
return parsed.hostname === outline.hostname;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user