This commit is contained in:
Tom Moor
2018-05-02 23:45:14 -07:00
parent d7327fefa2
commit f89eabaeff
2 changed files with 44 additions and 4 deletions

View 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;
}
}