Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getUrlLabelForGithub(rawUrl, options) {
try {
const url = new URL(rawUrl);
return replaceUrlPatterns(url.pathname, options.urlReplacementPatterns);
} catch (_) {
return replaceUrlPatterns(rawUrl, options.urlReplacementPatterns);
}
}
function getUrlLabelForGithub(rawUrl, options) {
try {
const url = new URL(rawUrl);
return replaceUrlPatterns(url.pathname, options.urlReplacementPatterns);
} catch (_) {
return replaceUrlPatterns(rawUrl, options.urlReplacementPatterns);
}
}
print(`Saving CI project ${project.name} (${project.id})\n`);
print(`Saving CI build (${build.id})\n`);
const lhrs = loadSavedLHRs();
const urlReplacementPatterns = options.urlReplacementPatterns.filter(Boolean);
const targetUrlMap = new Map();
const buildViewUrl = new URL(
`/app/projects/${project.slug}/compare/${build.id}`,
options.serverBaseUrl
);
for (const lhr of lhrs) {
const parsedLHR = JSON.parse(lhr);
const url = replaceUrlPatterns(parsedLHR.finalUrl, urlReplacementPatterns);
const run = await api.createRun({
projectId: project.id,
buildId: build.id,
representative: false,
url,
lhr,
});
buildViewUrl.searchParams.set('compareUrl', url);
targetUrlMap.set(parsedLHR.finalUrl, buildViewUrl.href);
print(`Saved LHR to ${options.serverBaseUrl} (${run.id})\n`);
}
buildViewUrl.searchParams.delete('compareUrl');
await api.sealBuild(build.projectId, build.id);
print(`Done saving build results to Lighthouse CI\n`);