pass encoded urls to fetch

This commit is contained in:
teddit 2020-12-06 21:59:40 +01:00
parent 0103e5fb7a
commit 073a1a94c9
2 changed files with 9 additions and 9 deletions

View File

@ -23,7 +23,7 @@ module.exports = function() {
}
resolve(obj)
} else {
fetch(`https://oauth.reddit.com/r/${subreddit}/about`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/r/${subreddit}/about`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()

View File

@ -45,7 +45,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
})
})()
} else {
fetch(`https://oauth.reddit.com/hot?api_type=json&g=GLOBAL&t=${past}${d}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/hot?api_type=json&g=GLOBAL&t=${past}${d}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -181,7 +181,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
})
})()
} else {
fetch(`https://oauth.reddit.com/${sortby}?api_type=json&g=GLOBAL&t=${past}${d}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/${sortby}?api_type=json&g=GLOBAL&t=${past}${d}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -270,7 +270,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
})
})()
} else {
fetch(`https://oauth.reddit.com/r/${subreddit}/search?api_type=json&q=${q}&restrict_sr=${restrict_sr}&include_over_18=${nsfw}&sort=${sortby}&t=${past}${d}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/r/${subreddit}/search?api_type=json&q=${q}&restrict_sr=${restrict_sr}&include_over_18=${nsfw}&sort=${sortby}&t=${past}${d}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -379,7 +379,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
}
})()
} else {
fetch(`https://oauth.reddit.com/r/${subreddit}/${sortby}?api_type=json&count=25&g=GLOBAL&t=${past}${d}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/r/${subreddit}/${sortby}?api_type=json&count=25&g=GLOBAL&t=${past}${d}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -503,7 +503,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
}
})()
} else {
fetch(`https://oauth.reddit.com${comments_url}?api_type=json&sort=${config.post_comments_sort}&context=${context}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com${comments_url}?api_type=json&sort=${config.post_comments_sort}&context=${context}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -617,13 +617,13 @@ module.exports = (app, redis, fetch, RedditAPI) => {
})
})()
} else {
fetch(`https://oauth.reddit.com/user/${user}/about`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/user/${user}/about`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
.then(json => {
user_data.about = json
fetch(`https://oauth.reddit.com/user/${user}/overview?limit=26${d}&sort=${sortby}&t=${past}`, redditApiGETHeaders())
fetch(encodeURI(`https://oauth.reddit.com/user/${user}/overview?limit=26${d}&sort=${sortby}&t=${past}`), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()
@ -725,7 +725,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
return res.redirect(`${post_url}?cursor=${page}&page=${page}`)
} else {
let url = `https://oauth.reddit.com/api/morechildren?api_type=json&children=${ids_to_show}&limit_children=false&link_id=t3_${post_id}&sort=${config.post_comments_sort}`
fetch(url, redditApiGETHeaders())
fetch(encodeURI(url), redditApiGETHeaders())
.then(result => {
if(result.status === 200) {
result.json()