MCPcopy Create free account
hub / github.com/hackmdio/codimd / sanitizeUrl

Function sanitizeUrl

public/js/utils.js:38–49  ·  view source on GitHub ↗
(rawUrl)

Source from the content-addressed store, hash-verified

36 * @returns {string} sanitized url
37 */
38export function sanitizeUrl (rawUrl) {
39 try {
40 const url = new URL(rawUrl)
41 if (url.protocol === 'http:' || url.protocol === 'https:') {
42 return url.toString()
43 }
44
45 throw new Error('Invalid protocol')
46 } catch (error) {
47 return 'about:blank'
48 }
49}
50
51// Check if URL is a PDF based on Content-Type header
52export async function isPdfUrl (url) {

Callers 1

finishViewFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected