MCPcopy Create free account
hub / github.com/Rello/analytics / getSafeReferenceUrl

Function getSafeReferenceUrl

js/reference.js:16–32  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

14'use strict';
15
16const getSafeReferenceUrl = function (value) {
17 if (typeof value !== 'string' || value.trim() === '') {
18 return null;
19 }
20
21 try {
22 const url = new URL(value, window.location.origin);
23
24 if (url.protocol !== 'http:' && url.protocol !== 'https:') {
25 return null;
26 }
27
28 return url.href;
29 } catch (error) {
30 return null;
31 }
32};
33
34if (!window.OCA) {
35 window.OCA = {};

Callers 1

reference.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected