Modified: trunk/Source/WebInspectorUI/ChangeLog (222215 => 222216)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-09-19 18:28:25 UTC (rev 222215)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-09-19 18:46:35 UTC (rev 222216)
@@ -1,5 +1,19 @@
2017-09-19 Joseph Pecoraro <[email protected]>
+ Web Inspector: Adopt named groups in complex regexes
+ https://bugs.webkit.org/show_bug.cgi?id=177117
+
+ Reviewed by Matt Baker.
+
+ * UserInterface/Base/URLUtilities.js:
+ (parseSecurityOrigin):
+ (parseDataURL):
+ (parseURL):
+ * UserInterface/Models/Color.js:
+ (WI.Color.fromString):
+
+2017-09-19 Joseph Pecoraro <[email protected]>
+
REGRESSION(r214494): Web Inspector: Ignore cache button does not work in Network tab
https://bugs.webkit.org/show_bug.cgi?id=177114
<rdar://problem/34505265>
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js (222215 => 222216)
--- trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js 2017-09-19 18:28:25 UTC (rev 222215)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js 2017-09-19 18:46:35 UTC (rev 222216)
@@ -61,13 +61,13 @@
{
securityOrigin = securityOrigin ? securityOrigin.trim() : "";
- var match = securityOrigin.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?$/i);
+ let match = securityOrigin.match(/^(?<scheme>[^:]+):\/\/(?<host>[^\/:]*)(?::(?<port>[\d]+))?$/i);
if (!match)
return {scheme: null, host: null, port: null};
- var scheme = match[1].toLowerCase();
- var host = match[2].toLowerCase();
- var port = Number(match[3]) || null;
+ let scheme = match.groups.scheme.toLowerCase();
+ let host = match.groups.host.toLowerCase();
+ let port = Number(match.groups.port) || null;
return {scheme, host, port};
}
@@ -78,15 +78,15 @@
return null;
// data:[<media type>][;charset=<character set>][;base64],<data>
- let match = url.match(/^data:([^;,]*)?(?:;charset=([^;,]*?))?(;base64)?,(.*)$/);
+ let match = url.match(/^data:(?<mime>[^;,]*)?(?:;charset=(?<charset>[^;,]*?))?(?<base64>;base64)?,(?<data>.*)$/);
if (!match)
return null;
let scheme = "data";
- let mimeType = match[1] || "text/plain";
- let charset = match[2] || "US-ASCII";
- let base64 = !!match[3];
- let data = ""
+ let mimeType = match.groups.mime || "text/plain";
+ let charset = match.groups.charset || "US-ASCII";
+ let base64 = !!match.groups.base64;
+ let data = ""
return {scheme, mimeType, charset, base64, data};
}
@@ -98,15 +98,15 @@
if (url.startsWith("data:"))
return {scheme: "data", host: null, port: null, path: null, queryString: null, fragment: null, lastPathComponent: null};
- var match = url.match(/^([^\/:]+):\/\/([^\/#:]*)(?::([\d]+))?(?:(\/[^#]*)?(?:#(.*))?)?$/i);
+ var match = url.match(/^(?<scheme>[^\/:]+):\/\/(?<host>[^\/#:]*)(?::(?<port>[\d]+))?(?:(?<path>\/[^#]*)?(?:#(?<fragment>.*))?)?$/i);
if (!match)
return {scheme: null, host: null, port: null, path: null, queryString: null, fragment: null, lastPathComponent: null};
- var scheme = match[1].toLowerCase();
- var host = match[2].toLowerCase();
- var port = Number(match[3]) || null;
- var wholePath = match[4] || null;
- var fragment = match[5] || null;
+ var scheme = match.groups.scheme.toLowerCase();
+ var host = match.groups.host.toLowerCase();
+ var port = Number(match.groups.port) || null;
+ var wholePath = match.groups.path || null;
+ var fragment = match.groups.fragment || null;
var path = wholePath;
var queryString = null;
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Color.js (222215 => 222216)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Color.js 2017-09-19 18:28:25 UTC (rev 222215)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Color.js 2017-09-19 18:46:35 UTC (rev 222216)
@@ -58,11 +58,11 @@
}
// Simple - #hex, rgb(), keyword, hsl()
- let simple = /^(?:#([0-9a-f]{3,8})|rgb\(([^)]+)\)|(\w+)|hsl\(([^)]+)\))$/i;
+ let simple = /^(?:#(?<hex>[0-9a-f]{3,8})|rgb\((?<rgb>[^)]+)\)|(?<keyword>\w+)|hsl\((?<hsl>[^)]+)\))$/i;
let match = colorString.match(simple);
if (match) {
- if (match[1]) { // hex
- let hex = match[1].toUpperCase();
+ if (match.groups.hex) {
+ let hex = match.groups.hex.toUpperCase();
let len = hex.length;
if (len === 3) {
return new WI.Color(WI.Color.Format.ShortHEX, [
@@ -94,8 +94,8 @@
]);
} else
return null;
- } else if (match[2]) { // rgb
- let rgb = match[2].split(/\s*,\s*/);
+ } else if (match.groups.rgb) {
+ let rgb = match.groups.rgb.split(/\s*,\s*/);
if (rgb.length !== 3)
return null;
return new WI.Color(WI.Color.Format.RGB, [
@@ -104,8 +104,8 @@
parseInt(rgb[2]),
1
]);
- } else if (match[3]) { // keyword
- let keyword = match[3].toLowerCase();
+ } else if (match.groups.keyword) {
+ let keyword = match.groups.keyword.toLowerCase();
if (!WI.Color.Keywords.hasOwnProperty(keyword))
return null;
let color = new WI.Color(WI.Color.Format.Keyword, WI.Color.Keywords[keyword].concat(1));
@@ -112,8 +112,8 @@
color.keyword = keyword;
color.original = colorString;
return color;
- } else if (match[4]) { // hsl
- let hsl = match[4].replace(/%/g, "").split(/\s*,\s*/);
+ } else if (match.groups.hsl) {
+ let hsl = match.groups.hsl.replace(/%/g, "").split(/\s*,\s*/);
if (hsl.length !== 3)
return null;
return new WI.Color(WI.Color.Format.HSL, [
@@ -126,11 +126,11 @@
}
// Advanced - rgba(), hsla()
- let advanced = /^(?:rgba\(([^)]+)\)|hsla\(([^)]+)\))$/i;
+ let advanced = /^(?:rgba\((?<rgba>[^)]+)\)|hsla\((?<hsla>[^)]+)\))$/i;
match = colorString.match(advanced);
if (match) {
- if (match[1]) { // rgba
- let rgba = match[1].split(/\s*,\s*/);
+ if (match.groups.rgba) {
+ let rgba = match.groups.rgba.split(/\s*,\s*/);
if (rgba.length !== 4)
return null;
return new WI.Color(WI.Color.Format.RGBA, [
@@ -139,8 +139,8 @@
parseInt(rgba[2]),
Number.constrain(parseFloat(rgba[3]), 0, 1)
]);
- } else if (match[2]) { // hsla
- let hsla = match[2].replace(/%/g, "").split(/\s*,\s*/);
+ } else if (match.groups.hsla) {
+ let hsla = match.groups.hsla.replace(/%/g, "").split(/\s*,\s*/);
if (hsla.length !== 4)
return null;
return new WI.Color(WI.Color.Format.HSLA, [