aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/url-helpers.js
blob: 750d1f00c4a771f6db5406e3fbe38c7645f72025 (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')('Franz: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;
}