fix(clean_url): encode ^
this is unrelated to address separator of adblock filter syntax https://adblockplus.org/filter-cheatsheet#blocking1 which does not need to be escaped uBO can handle this pattern just fine ||example.com/so%5Emany?ca^r=e^t^$all query string does not need to percent-encode ^, only pathname
This commit is contained in:
parent
fd8184a806
commit
62c754fe23
|
@ -30,7 +30,11 @@ for await (const line of createInterface({ input: process.stdin, terminal: false
|
|||
url = new URL(url.searchParams.get('url'))
|
||||
}
|
||||
|
||||
const outUrl = `${url.host.replace(/^www\./, '')}${url.pathname}${url.search}`
|
||||
url.host = url.host.replace(/^www\./, '')
|
||||
// nodejs does not percent-encode ^ yet
|
||||
// https://github.com/nodejs/node/issues/57313
|
||||
url.pathname = url.pathname.replaceAll('^', encodeURI('^'))
|
||||
const outUrl = `${url.host}${url.pathname}${url.search}`
|
||||
// remove trailing slash from domain except path #43
|
||||
.replace(/(^[^/]*)\/+$/, '$1')
|
||||
|
||||
|
|
Loading…
Reference in New Issue