MCPcopy
hub / github.com/diegomura/react-pdf / getAbsoluteLocalPath

Function getAbsoluteLocalPath

packages/image/src/resolve.js:12–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10export const IMAGE_CACHE = createCache({ limit: 30 });
11
12const getAbsoluteLocalPath = src => {
13 if (BROWSER) {
14 throw new Error('Cannot check local paths in client-side environment');
15 }
16
17 const { protocol, auth, host, port, hostname, path: pathname } = url.parse(
18 src,
19 );
20 const absolutePath = path.resolve(pathname);
21 if ((protocol && protocol !== 'file:') || auth || host || port || hostname) {
22 return undefined;
23 }
24 return absolutePath;
25};
26
27const fetchLocalFile = src =>
28 new Promise((resolve, reject) => {

Callers 2

fetchLocalFileFunction · 0.85
resolveImageFromUrlFunction · 0.85

Calls 2

resolveMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected