1// eslint-disable-next-line import/no-cycle 2import { getMetadata } from './utils.js'; 3 4/** 5 * Prefixes the link with the language root defined in the metadata 6 * @param link 7 * @returns {string|*} 8 */ 9// eslint-disable-next-line import/prefer-default-export 10export function updateLinkWithLangRoot(link) { 11 const langRoot = getMetadata('lang-root'); 12 if (!langRoot) return link; 13 try { 14 const url = new URL(link); 15 url.pathname = `${langRoot}${url.pathname}`; 16 return url.href; 17 } catch (e) { 18 // eslint-disable-next-line no-console 19 console.error('Could not update link with lang root', e); 20 return link; 21 } 22} 23 24export async function customFetch({ resource, withCacheRules }) { 25 const options = {}; 26 if (withCacheRules) { 27 const params = new URLSearchParams(window.location.search); 28 options.cache = params.get('cache') === 'off' ? 'reload' : 'default'; 29 } 30 return fetch(resource, options); 31}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.