| 10 | export const IMAGE_CACHE = createCache({ limit: 30 }); |
| 11 | |
| 12 | const 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 | |
| 27 | const fetchLocalFile = src => |
| 28 | new Promise((resolve, reject) => { |
no test coverage detected