Sha256: 419d783d0db9f474f9776d80c1f61e9da7ee738de49bfa82751e4c51fc5a50b6
Contents?: true
Size: 1013 Bytes
Versions: 23
Compression:
Stored size: 1013 Bytes
Contents
Discerner.Url = function (url) { this.url = url; }; Discerner.Url.prototype = { sub: function (params) { var url = this.url, newUrl = this.url, queryString = [], encodedArg = undefined, encodeParam = undefined, param = undefined; for (param in params) { if (params.hasOwnProperty(param)) { encodedParam = encodeURIComponent(param); encodedArg = encodeURIComponent(params[param]); newUrl = url.replace(':' + param, encodedArg); if (url == newUrl) { queryString.push(encodedParam + '=' + encodedArg); } url = newUrl; } } if (queryString.length > 0) { if (url.indexOf('?') > 0) { return url + queryString.join('&'); } else { return url + '?' + queryString.join('&'); } } else { return url; } }, parameters: function () { return $.map(this.url.match(/:\w+/g) || [], function (o, i) { return o.substring(1); }); } };
Version data entries
23 entries across 23 versions & 1 rubygems