MCPcopy Create free account
hub / github.com/dataease/SQLBot / sanitizeUrl

Function sanitizeUrl

frontend/public/swagger-ui-bundle.js:36140–36161  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

36138 return
36139 }
36140 }
36141 function sanitizeUrl(s) {
36142 if ('string' != typeof s || '' === s.trim()) return ''
36143 const o = s.trim(),
36144 i = 'about:blank'
36145 try {
36146 const s = `https://base${String(Math.random()).slice(2)}`,
36147 a = new URL(o, s),
36148 u = a.protocol.slice(0, -1)
36149 if (['javascript', 'data', 'vbscript'].includes(u.toLowerCase())) return i
36150 if (a.origin === s) {
36151 if (o.startsWith('/')) return `${a.pathname}${a.search}${a.hash}`
36152 if (o.startsWith('./') || o.startsWith('../')) {
36153 const s = o.match(/^(\.\.?\/)+/)[0]
36154 return `${s}${a.pathname.substring(1)}${a.search}${a.hash}`
36155 }
36156 return `${a.pathname.substring(1)}${a.search}${a.hash}`
36157 }
36158 return String(a)
36159 } catch {
36160 return i
36161 }
36162 }
36163 class ObjectModel extends Re.Component {
36164 render() {

Callers 15

renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
oas31_components_licenseFunction · 0.85

Calls 1

includesMethod · 0.45

Tested by

no test coverage detected