MCPcopy
hub / github.com/vitejs/vite / getRelativeUrlFromDocument

Function getRelativeUrlFromDocument

packages/vite/src/node/build.ts:1566–1571  ·  view source on GitHub ↗
(relativePath: string, umd = false)

Source from the content-addressed store, hash-verified

1564const getResolveUrl = (path: string, URL = 'URL') => `new ${URL}(${path}).href`
1565
1566const getRelativeUrlFromDocument = (relativePath: string, umd = false) =>
1567 getResolveUrl(
1568 `'${escapeId(partialEncodeURIPath(relativePath))}', ${
1569 umd ? `typeof document === 'undefined' ? location.href : ` : ''
1570 }document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`,
1571 )
1572
1573const getFileUrlFromFullPath = (path: string) =>
1574 `require('u' + 'rl').pathToFileURL(${path}).href`

Callers 1

build.tsFile · 0.85

Calls 3

partialEncodeURIPathFunction · 0.90
getResolveUrlFunction · 0.85
escapeIdFunction · 0.85

Tested by

no test coverage detected