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.
2018-05-03 06:45:14 +00:00
|
|
|
// @flow
|
2019-01-12 21:50:30 +00:00
|
|
|
import { parseDomain } from '../../shared/utils/domains';
|
2018-11-19 02:43:11 +00:00
|
|
|
|
2018-05-03 06:45:14 +00:00
|
|
|
export default function isInternalUrl(href: string) {
|
|
|
|
if (href[0] === '/') return true;
|
|
|
|
|
2018-11-19 02:43:11 +00:00
|
|
|
const outline = parseDomain(BASE_URL);
|
|
|
|
const parsed = parseDomain(href);
|
|
|
|
if (
|
|
|
|
parsed &&
|
|
|
|
outline &&
|
|
|
|
parsed.domain === outline.domain &&
|
|
|
|
parsed.tld === outline.tld
|
|
|
|
) {
|
|
|
|
return true;
|
2018-05-03 06:45:14 +00:00
|
|
|
}
|
2018-11-19 02:43:11 +00:00
|
|
|
|
|
|
|
return false;
|
2018-05-03 06:45:14 +00:00
|
|
|
}
|