diff --git a/helma/Url.js b/helma/Url.js index b9c7b40e..eab77b68 100644 --- a/helma/Url.js +++ b/helma/Url.js @@ -38,40 +38,76 @@ helma.Url = function(str) { str = str.replace(/[,.;:]\s/, ""); var parts = helma.Url.PATTERN.exec(str); + /** + * Protocol segment of this URL + */ this.protocol = parts[1]; if (!parts[2]) { if (parts[3]) + /** + * User name segment of this URL + */ this.user = parts[3]; } else { this.user = parts[2]; if (parts[3]) + /** + * Password segment of this URL + */ this.password = parts[3]; } if (!parts[4]) throw Error("Cannot create helma.Url: missing host part"); + /** + * Fully qualified domain name segment of this URL + */ this.domainName = parts[4]; // actually, the fully-qualified domain name var fqdnParts = this.domainName.split("."); if (fqdnParts.length < 3) this.host = ""; else { + /** + * Host name segment of this URL + */ this.host = fqdnParts[0]; fqdnParts.splice(0, 1); } + /** + * Top level domain name segment of this URL + */ this.topLevelDomain = fqdnParts[fqdnParts.length-1]; + /** + * Domain name segment of this URL + */ this.domain = fqdnParts.join("."); + /** + * Request path segment of this URL as string + */ this.pathString = parts[5] || ""; if (this.pathString.indexOf("/") == 0) this.pathString = this.pathString.substring(1); + /** + * Request path segment of this URL as array + */ this.path = this.pathString.split("/"); + /** + * File name segment of this URL + */ this.file = this.path.pop(); if (parts[6]) { + /** + * Query parameter segment of this URL as string + */ this.queryString = parts[6]; var pairs; + /** + * Query parameter segment of this URL as object + */ this.query = {}; parts = parts[6].split("&"); for (var i in parts) {