This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/app/utils/isInternalUrl.js
Tom Moor f89eabaeff Hooks
2018-05-02 23:45:14 -07:00

13 lines
272 B
JavaScript

// @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;
}
}