Skip to content

Commit

Permalink
Fail gracefully when the URL doesn't have hostPort or path (e.g. abou…
Browse files Browse the repository at this point in the history
…t, chrome, file URLs).

Relates to #3
  • Loading branch information
philikon committed Feb 14, 2010
1 parent 2d95bda commit 035d151
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions chrome/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,23 @@ var BarTap = {
tab.setAttribute("image", info.icon);
tab.label = info.title;
} else {
/* Set a meaningful part of the URI as tab label */
let hostPort = gotouri.hostPort;
let path = gotouri.path;
if (hostPort.substr(0, 4) == "www.") {
hostPort = hostPort.substr(4);
try {
/* Set a meaningful part of the URI as tab label */
let hostPort = gotouri.hostPort;
let path = gotouri.path;
if (hostPort.substr(0, 4) == "www.") {
hostPort = hostPort.substr(4);
}
if (path == "/") {
path = "";
}
tab.label = hostPort + path;
} catch (ex) {
/* Most likely gotouri.hostPort and gotouri.path failed.
Let's handle this gracefully. */
tab.label = gotouri.spec;
Components.utils.reportError(ex);
}
if (path == "/") {
path = "";
}
tab.label = hostPort + path;
}
}

Expand Down

0 comments on commit 035d151

Please sign in to comment.