Sha256: 5092aeac05b7e166492e4d4eea5fddb7aee98c3111a1ae2d637ef770fbceffa4
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
Faye.URI = Faye.extend(Faye.Class({ queryString: function() { var pairs = [], key; Faye.each(this.params, function(key, value) { pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); }); return pairs.join('&'); }, isLocal: function() { var host = Faye.URI.parse(Faye.ENV.location.href); var external = (host.hostname !== this.hostname) || (host.port !== this.port) || (host.protocol !== this.protocol); return !external; }, toURL: function() { return this.protocol + this.hostname + ':' + this.port + this.pathname + '?' + this.queryString(); } }), { parse: function(url, params) { if (typeof url !== 'string') return url; var location = new this(); var consume = function(name, pattern) { url = url.replace(pattern, function(match) { if (match) location[name] = match; return ''; }); }; consume('protocol', /^https?\:\/+/); consume('hostname', /^[a-z0-9\-]+(\.[a-z0-9\-]+)*\.[a-z0-9\-]{2,6}/i); consume('port', /^:[0-9]+/); Faye.extend(location, { protocol: 'http://', hostname: Faye.ENV.location.hostname, port: Faye.ENV.location.port }, false); if (!location.port) location.port = (location.protocol === 'https://') ? '443' : '80'; location.port = location.port.replace(/\D/g, ''); var parts = url.split('?'), path = parts.shift(), query = parts.join('?'), pairs = query ? query.split('&') : [], n = pairs.length, data = {}; while (n--) { parts = pairs[n].split('='); data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || ''); } Faye.extend(data, params); location.pathname = path; location.params = data; return location; } });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faye-0.1.0 | client/util/uri.js |
faye-0.1.1 | client/util/uri.js |