mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
processing/url: clean up cleanURL query exceptions
This commit is contained in:
parent
64b5990d81
commit
490bbf82ec
1 changed files with 19 additions and 8 deletions
|
@ -78,19 +78,30 @@ function aliasURL(url) {
|
||||||
function cleanURL(url) {
|
function cleanURL(url) {
|
||||||
assert(url instanceof URL);
|
assert(url instanceof URL);
|
||||||
const host = psl.parse(url.hostname).sld;
|
const host = psl.parse(url.hostname).sld;
|
||||||
|
|
||||||
let stripQuery = true;
|
let stripQuery = true;
|
||||||
|
|
||||||
if (host === 'pinterest') {
|
const limitQuery = (param) => {
|
||||||
url.hostname = 'pinterest.com'
|
url.search = `?${param}=` + encodeURIComponent(url.searchParams.get(param));
|
||||||
} else if (host === 'vk' && url.pathname.includes('/clip')) {
|
|
||||||
if (url.searchParams.get('z'))
|
|
||||||
url.search = '?z=' + encodeURIComponent(url.searchParams.get('z'));
|
|
||||||
stripQuery = false;
|
|
||||||
} else if (host === 'youtube' && url.searchParams.get('v')) {
|
|
||||||
url.search = '?v=' + encodeURIComponent(url.searchParams.get('v'));
|
|
||||||
stripQuery = false;
|
stripQuery = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (host) {
|
||||||
|
case "pinterest":
|
||||||
|
url.hostname = 'pinterest.com';
|
||||||
|
break;
|
||||||
|
case "vk":
|
||||||
|
if (url.pathname.includes('/clip') && url.searchParams.get('z')) {
|
||||||
|
limitQuery('z')
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "youtube":
|
||||||
|
if (url.searchParams.get('v')) {
|
||||||
|
limitQuery('v')
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (stripQuery) {
|
if (stripQuery) {
|
||||||
url.search = ''
|
url.search = ''
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue