blob: 2f429a25cfebb89711d1c7f604e5f58c6fd2a204 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import { URL } from 'url';
import { ALLOWED_PROTOCOLS } from '../config';
const debug = require('debug')('Ferdi:Helpers:url');
export function isValidExternalURL(url) {
const parsedUrl = new URL(url);
const isAllowed = ALLOWED_PROTOCOLS.includes(parsedUrl.protocol);
debug('protocol check is', isAllowed, 'for:', url);
return isAllowed;
}
|