Sha256: 31ebd6eb1f3fe69b029175c2360964c50463881202a730af2d5ed087cf0da7b2
Contents?: true
Size: 945 Bytes
Versions: 26
Compression:
Stored size: 945 Bytes
Contents
function hasTurbolinks() { return (typeof Turbolinks !== 'undefined' && Turbolinks.supported); } function turbolinksVisit(params) { const path = [window.location.pathname, '?', toQueryString(params)].join('') Turbolinks.visit(path); } function queryString() { return (window.location.search || '').replace(/^\?/, ''); } function queryStringToParams() { const decode = (value) => decodeURIComponent((value || '').replace(/\+/g, '%20')); return queryString() .split("&") .map(pair => pair.split("=")) .map(([key, value]) => { return { name: decode(key), value: decode(value) } }); } function toQueryString(params) { const encode = (value) => encodeURIComponent(value || ''); return params .map(({name, value}) => [ encode(name), encode(value) ]) .map(pair => pair.join('=')) .join('&') } export { hasTurbolinks, turbolinksVisit, queryString, queryStringToParams, toQueryString };
Version data entries
26 entries across 26 versions & 2 rubygems