Safer handling of broken URLs

This commit is contained in:
Peter Hedenskog 2025-12-15 14:10:43 +01:00
parent 9d8b03de0c
commit ecb940ee17
1 changed files with 13 additions and 7 deletions

View File

@ -95,7 +95,7 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
async processMessage(message) { async processMessage(message) {
const options = this.options; const options = this.options;
switch (message.type) { switch (message.type) {
// When sistespeed.io starts, a setup messages is posted on the queue // When sitespeed.io starts, a setup messages is posted on the queue
// and all plugins can tell other plugins that they are alive and are ready // and all plugins can tell other plugins that they are alive and are ready
// to receive configuration // to receive configuration
case 'sitespeedio.setup': { case 'sitespeedio.setup': {
@ -105,12 +105,18 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
if (this.options.urlMetaData) { if (this.options.urlMetaData) {
for (let url of Object.keys(this.options.urlMetaData)) { for (let url of Object.keys(this.options.urlMetaData)) {
const alias = this.options.urlMetaData[url]; const alias = this.options.urlMetaData[url];
const group = new URL(url).hostname; try {
this.allAlias[alias] = url; const group = new URL(url).hostname;
super.sendMessage('browsertime.alias', alias, { this.allAlias[alias] = url;
url, super.sendMessage('browsertime.alias', alias, {
group url,
}); group
});
} catch (error) {
log.error(
'Could not get group for URL:' + url + ' with error' + error
);
}
} }
} }