https://bugs.webkit.org/show_bug.cgi?id=83871
Reviewed by Yury Semikhatsky.
Source/WebCore:
There is a number of random properties created on Resource and NetworkRequest that represent various url
fragments. Display name is being based on them and sometimes requires fake Resource instance to be created.
This change (officially) introduces WebInspector.ParsedURL as a type that encapsulates this complexity.
This change also moves documentURL property into the Resource and NetworkRequest constructors and brushes up
factory methods used to create the objects.
* inspector/front-end/AuditRules.js:
(WebInspector.AuditRules.GzipRule.prototype._shouldCompress):
(WebInspector.AuditRules.CookieSizeRule.prototype.processCookies):
* inspector/front-end/Database.js:
(WebInspector.Database.prototype.get displayDomain):
* inspector/front-end/JavaScriptContextManager.js:
(WebInspector.FrameEvaluationContext.prototype.get displayName):
* inspector/front-end/NetworkManager.js:
(WebInspector.NetworkDispatcher.prototype.webSocketCreated):
(WebInspector.NetworkDispatcher.prototype._createNetworkRequest):
(get WebInspector):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.prototype._highlightNthMatchedRequest):
(WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
* inspector/front-end/NetworkRequest.js:
(WebInspector.NetworkRequest):
(WebInspector.NetworkRequest.prototype.set url):
(WebInspector.NetworkRequest.prototype.get documentURL):
(WebInspector.NetworkRequest.prototype.get parsedURL):
(WebInspector.NetworkRequest.prototype.get displayName):
(WebInspector.NetworkRequest.prototype.get folder):
* inspector/front-end/RequestHeadersView.js:
(WebInspector.RequestHeadersView.prototype._refreshUrlFragment):
* inspector/front-end/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.set url):
(WebInspector.Resource.prototype.get parsedURL):
(WebInspector.Resource.prototype.get frameId):
(WebInspector.Resource.prototype.get loaderId):
(WebInspector.Resource.prototype.get displayName):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype._onRequestUpdateDropped):
(WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
(WebInspector.ResourceTreeModel.prototype._createResourceFromFramePayload):
(WebInspector.ResourceTreeFrame.prototype._addRequest):
* inspector/front-end/ResourceUtils.js:
(WebInspector.ParsedURL):
(WebInspector.ParsedURL.prototype.get displayName):
(String.prototype.asParsedURL):
(WebInspector.displayDomain):
(WebInspector.resourceURLForRelatedNode.callback):
(WebInspector.resourceURLForRelatedNode):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.FrameTreeElement.prototype.frameNavigated):
(WebInspector.ApplicationCacheManifestTreeElement):
(WebInspector.ApplicationCacheFrameTreeElement.prototype._refreshTitles):
* inspector/front-end/utilities.js:
LayoutTests:
* inspector/debugger/raw-source-code.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114117
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+ Web Inspector: introduce ParsedURL type, clean up url and displayName mess in Resource and NetworkRequest.
+ https://bugs.webkit.org/show_bug.cgi?id=83871
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/debugger/raw-source-code.html:
+
+2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+
Web Inspector: extracting NetworkRequest from Resource (step 3)
https://bugs.webkit.org/show_bug.cgi?id=83802
{
var requestId = ++lastRequestId + "";
WebInspector.resourceTreeModel._addFrame(new WebInspector.ResourceTreeFrame(WebInspector.resourceTreeModel, null, {id: "frame-id"}));
- var request = new WebInspector.NetworkRequest(requestId, "http://fake.url", "frame-id", "loader-id");
+ var request = new WebInspector.NetworkRequest(requestId, "http://fake.url", "http://fake.url", "frame-id", "loader-id");
request.type = type === "document" ? WebInspector.resourceTypes.Document : WebInspector.resourceTypes.Script;
WebInspector.networkManager._dispatcher._startNetworkRequest(request);
2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+ Web Inspector: introduce ParsedURL type, clean up url and displayName mess in Resource and NetworkRequest.
+ https://bugs.webkit.org/show_bug.cgi?id=83871
+
+ Reviewed by Yury Semikhatsky.
+
+ There is a number of random properties created on Resource and NetworkRequest that represent various url
+ fragments. Display name is being based on them and sometimes requires fake Resource instance to be created.
+ This change (officially) introduces WebInspector.ParsedURL as a type that encapsulates this complexity.
+
+ This change also moves documentURL property into the Resource and NetworkRequest constructors and brushes up
+ factory methods used to create the objects.
+
+ * inspector/front-end/AuditRules.js:
+ (WebInspector.AuditRules.GzipRule.prototype._shouldCompress):
+ (WebInspector.AuditRules.CookieSizeRule.prototype.processCookies):
+ * inspector/front-end/Database.js:
+ (WebInspector.Database.prototype.get displayDomain):
+ * inspector/front-end/JavaScriptContextManager.js:
+ (WebInspector.FrameEvaluationContext.prototype.get displayName):
+ * inspector/front-end/NetworkManager.js:
+ (WebInspector.NetworkDispatcher.prototype.webSocketCreated):
+ (WebInspector.NetworkDispatcher.prototype._createNetworkRequest):
+ (get WebInspector):
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkLogView.prototype._highlightNthMatchedRequest):
+ (WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
+ * inspector/front-end/NetworkRequest.js:
+ (WebInspector.NetworkRequest):
+ (WebInspector.NetworkRequest.prototype.set url):
+ (WebInspector.NetworkRequest.prototype.get documentURL):
+ (WebInspector.NetworkRequest.prototype.get parsedURL):
+ (WebInspector.NetworkRequest.prototype.get displayName):
+ (WebInspector.NetworkRequest.prototype.get folder):
+ * inspector/front-end/RequestHeadersView.js:
+ (WebInspector.RequestHeadersView.prototype._refreshUrlFragment):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource):
+ (WebInspector.Resource.prototype.set url):
+ (WebInspector.Resource.prototype.get parsedURL):
+ (WebInspector.Resource.prototype.get frameId):
+ (WebInspector.Resource.prototype.get loaderId):
+ (WebInspector.Resource.prototype.get displayName):
+ * inspector/front-end/ResourceTreeModel.js:
+ (WebInspector.ResourceTreeModel.prototype._onRequestUpdateDropped):
+ (WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
+ (WebInspector.ResourceTreeModel.prototype._createResourceFromFramePayload):
+ (WebInspector.ResourceTreeFrame.prototype._addRequest):
+ * inspector/front-end/ResourceUtils.js:
+ (WebInspector.ParsedURL):
+ (WebInspector.ParsedURL.prototype.get displayName):
+ (String.prototype.asParsedURL):
+ (WebInspector.displayDomain):
+ (WebInspector.resourceURLForRelatedNode.callback):
+ (WebInspector.resourceURLForRelatedNode):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.FrameTreeElement.prototype.frameNavigated):
+ (WebInspector.ApplicationCacheManifestTreeElement):
+ (WebInspector.ApplicationCacheFrameTreeElement.prototype._refreshTitles):
+ * inspector/front-end/utilities.js:
+
+2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+
Web Inspector: extracting NetworkRequest from Resource (step 3)
https://bugs.webkit.org/show_bug.cgi?id=83802
_shouldCompress: function(request)
{
- return request.type.isTextType() && request.domain && request.resourceSize !== undefined && request.resourceSize > 150;
+ return request.type.isTextType() && request.parsedURL.host && request.resourceSize !== undefined && request.resourceSize > 150;
}
}
function collectorCallback(request, cookie)
{
- var cookies = cookiesPerResourceDomain[request.domain];
+ var cookies = cookiesPerResourceDomain[request.parsedURL.host];
if (!cookies) {
cookies = [];
- cookiesPerResourceDomain[request.domain] = cookies;
+ cookiesPerResourceDomain[request.parsedURL.host] = cookies;
}
cookies.push(cookie);
}
/** @return {string} */
get displayDomain()
{
- return WebInspector.Resource.prototype.__lookupGetter__("displayDomain").call(this);
+ return WebInspector.displayDomain(this._domain);
},
/**
if (!this._frame.parentFrame)
return "<top frame>";
var name = this._frame.name || "";
- var subtitle = WebInspector.Resource.displayName(this._frame.url);
+ var subtitle = new WebInspector.ParsedURL(this._frame.url).displayName;
if (subtitle) {
if (!name)
return subtitle;
*/
webSocketCreated: function(requestId, requestURL)
{
- var networkRequest = new WebInspector.NetworkRequest(requestId, requestURL, "", "");
+ var networkRequest = new WebInspector.NetworkRequest(requestId, requestURL, "", "", "");
networkRequest.type = WebInspector.resourceTypes.WebSocket;
this._startNetworkRequest(networkRequest);
},
*/
_createNetworkRequest: function(requestId, frameId, loaderId, url, documentURL, initiator, stackTrace)
{
- var networkRequest = new WebInspector.NetworkRequest(requestId, url, frameId, loaderId);
- networkRequest.documentURL = documentURL;
+ var networkRequest = new WebInspector.NetworkRequest(requestId, url, documentURL, frameId, loaderId);
networkRequest.initiator = initiator;
networkRequest.stackTrace = stackTrace;
return networkRequest;
return;
var nameMatched = request.displayName && request.displayName.match(this._searchRegExp);
- var pathMatched = request.path && request.folder.match(this._searchRegExp);
+ var pathMatched = request.parsedURL.path && request.folder.match(this._searchRegExp);
if (!nameMatched && pathMatched && !this._largerRequestsButton.toggled)
this._toggleLargerRequests();
this._nameCell.appendChild(document.createTextNode(this._fileName()));
- var subtitle = this._request.displayDomain;
+ var subtitle = WebInspector.displayDomain(this._request.parsedURL.host);
- if (this._request.path)
+ if (this._request.parsedURL.path)
subtitle += this._request.folder;
this._appendSubtitle(this._nameCell, subtitle);
*
* @param {NetworkAgent.RequestId} requestId
* @param {string} url
+ * @param {string} documentURL
* @param {NetworkAgent.FrameId} frameId
* @param {NetworkAgent.LoaderId} loaderId
*/
-WebInspector.NetworkRequest = function(requestId, url, frameId, loaderId)
+WebInspector.NetworkRequest = function(requestId, url, documentURL, frameId, loaderId)
{
this._requestId = requestId;
- this._url = url;
+ this.url = url;
+ this._documentURL = documentURL;
this._frameId = frameId;
this._loaderId = loaderId;
this._startTime = -1;
this._content = undefined;
this._contentEncoded = false;
this._pendingContentCallbacks = [];
-
- delete this._parsedQueryParameters;
-
- var parsedURL = url.asParsedURL();
- this.domain = parsedURL ? parsedURL.host : "";
- this.path = parsedURL ? parsedURL.path : "";
- this.urlFragment = parsedURL ? parsedURL.fragment : "";
- this.lastPathComponent = parsedURL ? parsedURL.lastPathComponent : "";
}
WebInspector.NetworkRequest.Events = {
return this._url;
},
+ set url(x)
+ {
+ if (this._url === x)
+ return;
+
+ this._url = x;
+ this._parsedURL = new WebInspector.ParsedURL(x);
+ delete this._parsedQueryParameters;
+ },
+
+ /**
+ * @type {string}
+ */
+ get documentURL()
+ {
+ return this._documentURL;
+ },
+
+ get parsedURL()
+ {
+ return this._parsedURL;
+ },
+
/**
* @type {NetworkAgent.FrameId}
*/
*/
get displayName()
{
- if (this._displayName)
- return this._displayName;
- this._displayName = this.lastPathComponent;
- if (!this._displayName)
- this._displayName = this.displayDomain;
- if (!this._displayName && this.url)
- this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
- if (this._displayName === "/")
- this._displayName = this.url;
- return this._displayName;
+ return this._parsedURL.displayName;
},
/**
*/
get folder()
{
- var path = this.path;
+ var path = this._parsedURL.path;
var indexOfQuery = path.indexOf("?");
if (indexOfQuery !== -1)
path = path.substring(0, indexOfQuery);
},
/**
- * @type {string}
- */
- get displayDomain()
- {
- // WebInspector.Database calls this, so don't access more than this.domain.
- if (this.domain && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && this.domain !== WebInspector.inspectedPageDomain)))
- return this.domain;
- return "";
- },
-
- /**
* @type {WebInspector.ResourceType}
*/
get type()
_refreshUrlFragment: function()
{
- var urlFragment = this._request.urlFragment;
+ var urlFragment = this._request.parsedURL.fragment;
this._urlFragmentTreeElement.hidden = !urlFragment;
if (!urlFragment)
*
* @param {?WebInspector.NetworkRequest} request
* @param {string} url
- * @param {string} frameId
- * @param {?NetworkAgent.LoaderId} loaderId
+ * @param {string} documentURL
+ * @param {NetworkAgent.FrameId} frameId
+ * @param {NetworkAgent.LoaderId} loaderId
+ * @param {WebInspector.ResourceType=} type
+ * @param {string=} mimeType
*/
-WebInspector.Resource = function(request, url, frameId, loaderId)
+WebInspector.Resource = function(request, url, documentURL, frameId, loaderId, type, mimeType)
{
this._request = request;
if (this._request)
this._request.setResource(this);
this.url = url;
- this.frameId = frameId;
- this.loaderId = loaderId;
- this._type = WebInspector.resourceTypes.Other;
+ this._documentURL = documentURL;
+ this._frameId = frameId;
+ this._loaderId = loaderId;
+ this._type = type || WebInspector.resourceTypes.Other;
+ this._mimeType = mimeType;
this.history = [];
this._content = undefined;
this._pendingContentCallbacks = [];
}
-/**
- * @param {string} url
- * @return {string}
- */
-WebInspector.Resource.displayName = function(url)
-{
- return new WebInspector.Resource(null, url, "", null).displayName;
-}
-
WebInspector.Resource._domainModelBindings = [];
/**
},
/**
- * @return {WebInspector.Resource}
- */
- resource: function()
- {
- return this;
- },
-
- /**
* @type {string}
*/
get url()
set url(x)
{
- if (this._url === x)
- return;
-
this._url = x;
+ this._parsedURL = new WebInspector.ParsedURL(x);
+ },
- var parsedURL = x.asParsedURL();
- this.domain = parsedURL ? parsedURL.host : "";
- this.path = parsedURL ? parsedURL.path : "";
- this.lastPathComponent = parsedURL ? parsedURL.lastPathComponent : "";
+ get parsedURL()
+ {
+ return this._parsedURL;
},
/**
return this._documentURL;
},
- set documentURL(x)
- {
- this._documentURL = x;
- },
-
/**
- * @type {string}
+ * @type {NetworkAgent.FrameId}
*/
- get displayName()
+ get frameId()
{
- if (this._displayName)
- return this._displayName;
- this._displayName = this.lastPathComponent;
- if (!this._displayName)
- this._displayName = this.displayDomain;
- if (!this._displayName && this.url)
- this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
- if (this._displayName === "/")
- this._displayName = this.url;
- return this._displayName;
+ return this._frameId;
},
/**
- * @type {string}
+ * @type {NetworkAgent.LoaderId}
*/
- get folder()
+ get loaderId()
{
- var path = this.path;
- var indexOfQuery = path.indexOf("?");
- if (indexOfQuery !== -1)
- path = path.substring(0, indexOfQuery);
- var lastSlashIndex = path.lastIndexOf("/");
- return lastSlashIndex !== -1 ? path.substring(0, lastSlashIndex) : "";
+ return this._loaderId;
},
/**
* @type {string}
*/
- get displayDomain()
+ get displayName()
{
- // WebInspector.Database calls this, so don't access more than this.domain.
- if (this.domain && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && this.domain !== WebInspector.inspectedPageDomain)))
- return this.domain;
- return "";
+ return this._parsedURL.displayName;
},
/**
return this._request ? this._request.type : this._type;
},
- set type(x)
- {
- this._type = x;
- },
-
/**
* @type {string}
*/
return this._request ? this._request.mimeType : this._mimeType;
},
- set mimeType(x)
- {
- this._mimeType = x;
- },
-
/**
* @type {Array.<WebInspector.ConsoleMessage>}
*/
if (frame._resourcesMap[url])
return;
- var resource = this._createResource(url, frame.url, frameId, event.data.loaderId);
- resource.type = WebInspector.resourceTypes[event.data.resourceType];
- resource.mimeType = event.data.mimeType;
- resource.finished = true;
+ var resource = new WebInspector.Resource(null, url, frame.url, frameId, event.data.loaderId, WebInspector.resourceTypes[event.data.resourceType], event.data.mimeType);
frame._addResource(resource);
},
var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, framePayload);
// Create frame resource.
- var frameResource = this._createResourceFromFramePayload(framePayload, framePayload.url);
- frameResource.mimeType = framePayload.mimeType;
- frameResource.type = WebInspector.resourceTypes.Document;
- frameResource.finished = true;
+ var frameResource = this._createResourceFromFramePayload(framePayload, framePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType);
if (frame.isMainFrame())
WebInspector.inspectedPageURL = frameResource.url;
// Create frame subresources.
for (var i = 0; i < frameTreePayload.resources.length; ++i) {
var subresource = frameTreePayload.resources[i];
- var resource = this._createResourceFromFramePayload(framePayload, subresource.url);
- resource.type = WebInspector.resourceTypes[subresource.type];
- resource.mimeType = subresource.mimeType;
- resource.finished = true;
+ var resource = this._createResourceFromFramePayload(framePayload, subresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeType);
frame._addResource(resource);
}
},
/**
* @param {PageAgent.Frame} frame
* @param {string} url
+ * @param {WebInspector.ResourceType} type
+ * @param {string} mimeType
* @return {WebInspector.Resource}
*/
- _createResourceFromFramePayload: function(frame, url)
+ _createResourceFromFramePayload: function(frame, url, type, mimeType)
{
- return this._createResource(url, frame.url, frame.id, frame.loaderId);
- },
-
- /**
- * @param {string} url
- * @param {string} documentURL
- * @param {NetworkAgent.FrameId} frameId
- * @param {NetworkAgent.LoaderId} loaderId
- * @return {WebInspector.Resource}
- */
- _createResource: function(url, documentURL, frameId, loaderId)
- {
- var resource = new WebInspector.Resource(null, url, frameId, loaderId);
- resource.documentURL = documentURL;
- return resource;
+ return new WebInspector.Resource(null, url, frame.url, frame.id, frame.loaderId, type, mimeType);
}
}
// Already in the tree, we just got an extra update.
return resource;
}
- resource = new WebInspector.Resource(request, request.url, request.frameId, request.loaderId);
+ resource = new WebInspector.Resource(request, request.url, request.documentURL, request.frameId, request.loaderId);
this._resourcesMap[resource.url] = resource;
this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
return resource;
*/
/**
+ * @constructor
+ * @param {String|string} url
+ */
+WebInspector.ParsedURL = function(url)
+{
+ this.isValid = false;
+ this.url = url;
+ this.scheme = "";
+ this.host = "";
+ this.port = "";
+ this.path = "";
+ this.fragment = "";
+ this.lastPathComponent = "";
+
+ // RegExp groups:
+ // 1 - scheme
+ // 2 - hostname
+ // 3 - ?port
+ // 4 - ?path
+ // 5 - ?fragment
+ var match = url.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
+ if (!match) {
+ if (this == "about:blank") {
+ this.isValid = true;
+ this.scheme = "about";
+ this.host = "blank";
+ this.path = "/";
+ return;
+ }
+ return;
+ }
+
+ this.isValid = true;
+ this.scheme = match[1].toLowerCase();
+ this.host = match[2];
+ this.port = match[3];
+ this.path = match[4] || "/";
+ this.fragment = match[5];
+
+ if (this.path) {
+ // First cut the query params.
+ var path = this.path;
+ var indexOfQuery = path.indexOf("?");
+ if (indexOfQuery !== -1)
+ path = path.substring(0, indexOfQuery);
+
+ // Then take last path component.
+ var lastSlashIndex = path.lastIndexOf("/");
+ if (lastSlashIndex !== -1) {
+ this.firstPathComponents = path.substring(0, lastSlashIndex + 1);
+ this.lastPathComponent = path.substring(lastSlashIndex + 1);
+ }
+ }
+}
+
+WebInspector.ParsedURL.prototype = {
+ get displayName()
+ {
+ if (this._displayName)
+ return this._displayName;
+
+ this._displayName = this.lastPathComponent;
+ if (!this._displayName)
+ this._displayName = WebInspector.displayDomain(this.host);
+ if (!this._displayName && this.url)
+ this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
+ if (this._displayName === "/")
+ this._displayName = this.url;
+ return this._displayName;
+ }
+}
+/**
+ * @return {?WebInspector.ParsedURL}
+ */
+String.prototype.asParsedURL = function()
+{
+ var parsedURL = new WebInspector.ParsedURL(this);
+ if (parsedURL.isValid)
+ return parsedURL;
+ return null;
+}
+
+/**
* @param {string} url
* @return {?WebInspector.Resource}
*/
}
/**
+ * @param {string} host
+ */
+WebInspector.displayDomain = function(host)
+{
+ if (host && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && host !== WebInspector.inspectedPageDomain)))
+ return host;
+ return "";
+}
+
+/**
* @param {string} url
* @return {string}
*/
var resourceURL = url;
function callback(resource)
{
- if (resource.path === url) {
+ if (resource.parsedURL.path === url) {
resourceURL = resource.url;
return true;
}
this._frameId = frame.id;
this.titleText = frame.name;
- this.subtitleText = WebInspector.Resource.displayName(frame.url);
+ this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
this._categoryElements = {};
this._treeElementForResource = {};
*/
WebInspector.ApplicationCacheManifestTreeElement = function(storagePanel, manifestURL)
{
- var title = WebInspector.Resource.displayName(manifestURL);
+ var title = new WebInspector.ParsedURL(manifestURL).displayName;
WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["application-cache-storage-tree-item"]);
this.tooltip = manifestURL;
this._manifestURL = manifestURL;
return;
}
this.titleText = frame.name;
- this.subtitleText = WebInspector.Resource.displayName(frame.url);
+ this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
},
frameNavigated: function()
return this._lineEndings;
}
-String.prototype.asParsedURL = function()
-{
- // RegExp groups:
- // 1 - scheme
- // 2 - hostname
- // 3 - ?port
- // 4 - ?path
- // 5 - ?fragment
- var match = this.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
- if (!match) {
- if (this == "about:blank") {
- return { scheme: "about",
- host: "blank",
- path: "/",
- lastPathComponent: ""};
- }
- return null;
- }
- var result = {};
- result.scheme = match[1].toLowerCase();
- result.host = match[2];
- result.port = match[3];
- result.path = match[4] || "/";
- result.fragment = match[5];
-
- result.lastPathComponent = "";
- if (result.path) {
- // First cut the query params.
- var path = result.path;
- var indexOfQuery = path.indexOf("?");
- if (indexOfQuery !== -1)
- path = path.substring(0, indexOfQuery);
-
- // Then take last path component.
- var lastSlashIndex = path.lastIndexOf("/");
- if (lastSlashIndex !== -1) {
- result.firstPathComponents = path.substring(0, lastSlashIndex + 1);
- result.lastPathComponent = path.substring(lastSlashIndex + 1);
- }
- }
- return result;
-}
-
String.prototype.escapeCharacters = function(chars)
{
var foundChar = false;