JezK
Edit File: location.js
// Generated by CoffeeScript 2.7.0 (function() { Turbolinks.Location = (function() { var addTrailingSlash, getPrefixURL, stringEndsWith, stringStartsWith; class Location { static wrap(value) { if (value instanceof this) { return value; } else { return new this(value); } } constructor(url = "") { var anchorLength, linkWithAnchor; linkWithAnchor = document.createElement("a"); linkWithAnchor.href = url.toString(); this.absoluteURL = linkWithAnchor.href; anchorLength = linkWithAnchor.hash.length; if (anchorLength < 2) { this.requestURL = this.absoluteURL; } else { this.requestURL = this.absoluteURL.slice(0, -anchorLength); this.anchor = linkWithAnchor.hash.slice(1); } } getOrigin() { return this.absoluteURL.split("/", 3).join("/"); } getPath() { var ref, ref1; return (ref = (ref1 = this.requestURL.match(/\/\/[^\/]*(\/[^?;]*)/)) != null ? ref1[1] : void 0) != null ? ref : "/"; } getPathComponents() { return this.getPath().split("/").slice(1); } getLastPathComponent() { return this.getPathComponents().slice(-1)[0]; } getExtension() { var ref, ref1; return (ref = (ref1 = this.getLastPathComponent().match(/\.[^.]*$/)) != null ? ref1[0] : void 0) != null ? ref : ""; } isHTML() { return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/); } isPrefixedBy(location) { var prefixURL; prefixURL = getPrefixURL(location); return this.isEqualTo(location) || stringStartsWith(this.absoluteURL, prefixURL); } isEqualTo(location) { return this.absoluteURL === (location != null ? location.absoluteURL : void 0); } toCacheKey() { return this.requestURL; } toJSON() { return this.absoluteURL; } toString() { return this.absoluteURL; } valueOf() { return this.absoluteURL; } }; // Private getPrefixURL = function(location) { return addTrailingSlash(location.getOrigin() + location.getPath()); }; addTrailingSlash = function(url) { if (stringEndsWith(url, "/")) { return url; } else { return url + "/"; } }; stringStartsWith = function(string, prefix) { return string.slice(0, prefix.length) === prefix; }; stringEndsWith = function(string, suffix) { return string.slice(-suffix.length) === suffix; }; return Location; }).call(this); }).call(this);