diff options
Diffstat (limited to 'src/helpers/url-helpers.js')
-rw-r--r-- | src/helpers/url-helpers.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/helpers/url-helpers.js b/src/helpers/url-helpers.js new file mode 100644 index 000000000..750d1f00c --- /dev/null +++ b/src/helpers/url-helpers.js | |||
@@ -0,0 +1,15 @@ | |||
1 | import { URL } from 'url'; | ||
2 | |||
3 | import { ALLOWED_PROTOCOLS } from '../config'; | ||
4 | |||
5 | const debug = require('debug')('Franz:Helpers:url'); | ||
6 | |||
7 | export function isValidExternalURL(url) { | ||
8 | const parsedUrl = new URL(url); | ||
9 | |||
10 | const isAllowed = ALLOWED_PROTOCOLS.includes(parsedUrl.protocol); | ||
11 | |||
12 | debug('protocol check is', isAllowed, 'for:', url); | ||
13 | |||
14 | return isAllowed; | ||
15 | } | ||