mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-13 05:37:44 +02:00
fix handling of URLs containing utf-8 characters
Merge pull request #253 from dumbmoron/fix-utf8-urls
This commit is contained in:
@ -67,8 +67,7 @@ export default async function(host, patternMatch, url, lang, obj) {
|
||||
case "reddit":
|
||||
r = await reddit({
|
||||
sub: patternMatch["sub"],
|
||||
id: patternMatch["id"],
|
||||
title: patternMatch["title"]
|
||||
id: patternMatch["id"]
|
||||
});
|
||||
break;
|
||||
case "douyin":
|
||||
|
@ -48,7 +48,7 @@ async function getAccessToken() {
|
||||
}
|
||||
|
||||
export default async function(obj) {
|
||||
const url = new URL(`https://www.reddit.com/r/${obj.sub}/comments/${obj.id}/${obj.title}.json`);
|
||||
const url = new URL(`https://www.reddit.com/r/${obj.sub}/comments/${obj.id}.json`);
|
||||
|
||||
const accessToken = await getAccessToken();
|
||||
if (accessToken) url.hostname = 'oauth.reddit.com';
|
||||
|
@ -8,8 +8,7 @@ export const testers = {
|
||||
|
||||
"youtube": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 11),
|
||||
|
||||
"reddit": (patternMatch) => (patternMatch["sub"] && patternMatch["id"] && patternMatch["title"]
|
||||
&& patternMatch["sub"].length <= 22 && patternMatch["id"].length <= 10 && patternMatch["title"].length <= 96),
|
||||
"reddit": (patternMatch) => (patternMatch.sub?.length <= 22 && patternMatch.id?.length <= 10),
|
||||
|
||||
"tiktok": (patternMatch) => ((patternMatch["user"] && patternMatch["postId"] && patternMatch["postId"].length <= 21)
|
||||
|| (patternMatch["id"] && patternMatch["id"].length <= 13)),
|
||||
|
Reference in New Issue
Block a user