const encodeRouteParam = (value) => encodeURIComponent(String(value)); export const buildFileQuery = (path, params = {}, options = {}) => { const { encode = false } = options; const entries = Object.entries(params).filter(([, value]) => { return value !== undefined && value !== null; }); if (entries.length === 0) { return path; } const query = entries .map(([key, value]) => { if (!encode) { return `${key}=${String(value)}`; } return `${encodeRouteParam(key)}=${encodeRouteParam(value)}`; }) .join("&"); return `${path}?${query}`; }; export const withBaseUrl = (baseUrl, route) => { return `${baseUrl}${route}`; }; export const appendQuerySuffix = (route, suffix = "") => { return `${route}${suffix}`; }; export const appendHashSuffix = (route, hashBuilder) => { return appendQuerySuffix(route, hashBuilder(route)); };