Bug 1276349 - Fix DAMP regression by speeding up _isURL. r=bgrins

MozReview-Commit-ID: C7khVe46Vjk

--HG--
extra : rebase_source : 991395b28fdc0bc6296af866a3e7b4ddd6eda9c2
This commit is contained in:
Tom Tromey 2016-07-05 11:33:01 -06:00
parent eaa1f24d14
commit 6a91e5346c

View File

@ -33,6 +33,8 @@ const nodeConstants = require("devtools/shared/dom-node-constants");
const MAX_STRING_GRIP_LENGTH = 36;
const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
const validProtocols = /^(http|https|ftp|data|javascript|resource|chrome):/i;
// Constants for compatibility with the Web Console output implementation before
// bug 778766.
// TODO: remove these once bug 778766 is fixed.
@ -2223,9 +2225,11 @@ Widgets.URLString.prototype = extend(Widgets.BaseWidget.prototype, {
*/
_isURL: function (token) {
try {
let url = new URL(token);
return ["http:", "https:", "ftp:", "data:", "javascript:",
"resource:", "chrome:"].includes(url.protocol);
if (!validProtocols.test(token)) {
return false;
}
new URL(token);
return true;
} catch (e) {
return false;
}