using new URLSearchParam api
continuous-integration/drone/push Build encountered an error Details

This commit is contained in:
James Tomasino 2019-10-31 16:31:44 +00:00
parent 6a73861596
commit e0f2955546
1 changed files with 17 additions and 1 deletions

View File

@ -24,11 +24,27 @@
if (typeof Array.from === 'function') {
Array.from(document.querySelectorAll('a')).map( el => {
var url = el.href
el.href = url + (url.indexOf('?') !== -1 ? "&" : "?") + 'dark=1';
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
var baseURL = url.split('?')[0]
const params = new URLSearchParams(p)
params.append('dark', 1)
p = params.toString()
el.href = baseURL + (p ? '?' + p : '')
})
}
} else {
document.body.classList.remove('dark')
if (typeof Array.from === 'function') {
Array.from(document.querySelectorAll('a')).map( el => {
var url = el.href
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
var baseURL = url.split('?')[0]
const params = new URLSearchParams(p)
params.delete('dark')
p = params.toString()
el.href = baseURL + (p ? '?' + p : '')
})
}
}
}