MCPcopy
hub / github.com/docsifyjs/docsify / isExternal

Function isExternal

src/core/util/core.js:75–103  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

73 * @returns {Boolean} True if the passed-in url is external
74 */
75export function isExternal(url) {
76 let match = url.match(
77 /^([^:/?#]+:)?(?:\/{2,}([^/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/
78 );
79
80 if (
81 typeof match[1] === 'string' &&
82 match[1].length > 0 &&
83 match[1].toLowerCase() !== location.protocol
84 ) {
85 return true;
86 }
87 if (
88 typeof match[2] === 'string' &&
89 match[2].length > 0 &&
90 match[2].replace(
91 new RegExp(
92 ':(' + { 'http:': 80, 'https:': 443 }[location.protocol] + ')?$'
93 ),
94 ''
95 ) !== location.host
96 ) {
97 return true;
98 }
99 if (/^\/\\/.test(url)) {
100 return true;
101 }
102 return false;
103}

Callers 4

_fetchMethod · 0.90
onchangeMethod · 0.90
onchangeMethod · 0.90
core-util.test.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…