From 543f01641c5faaee754a9ece99310cfed997e598 Mon Sep 17 00:00:00 2001 From: teddit Date: Thu, 22 Apr 2021 20:57:32 +0200 Subject: [PATCH] encode url for fetching suggested subreddits --- routes.js | 2 +- views/search.pug | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routes.js b/routes.js index 67f7a6e..b24f161 100644 --- a/routes.js +++ b/routes.js @@ -925,7 +925,7 @@ module.exports = (app, redis, fetch, RedditAPI) => { json.suggested_subreddits = {} if(restrict_sr === 'off' && before == '' && after == '') { let url = `https://reddit.com/subreddits/search.json?q=${q}&include_over_18=${nsfw}&limit=3` - const response = await fetch(url) + const response = await fetch(encodeURI(url)) const data = await response.json() json.suggested_subreddits = data } diff --git a/views/search.pug b/views/search.pug index 6d2a12f..e3e1149 100644 --- a/views/search.pug +++ b/views/search.pug @@ -121,9 +121,9 @@ html h2 #{suggested_subreddit.data.display_name_prefixed}: #{cleanTitle(suggested_subreddit.data.title)} .sub-button if subbed_to_this_subreddit - a(href="/unsubscribe/" + suggested_subreddit.data.display_name + "?b=/r/" + subreddit + "?q=" + q + "§nsfw=" + nsfw + "", class="sub-to-subreddit gray", title="subscriptions are saved in your browser's cookies") unsubscribe + a(href="/unsubscribe/" + suggested_subreddit.data.display_name + "?b=/r/" + subreddit + "/search?q=" + q + "§nsfw=" + nsfw + "", class="sub-to-subreddit gray", title="subscriptions are saved in your browser's cookies") unsubscribe else - a(href="/subscribe/" + suggested_subreddit.data.display_name + "?b=/r/" + subreddit + "?q=" + q + "§nsfw=" + nsfw + "", class="sub-to-subreddit", title="subscriptions are saved in your browser's cookies") subscribe + a(href="/subscribe/" + suggested_subreddit.data.display_name + "?b=/r/" + subreddit + "/search?q=" + q + "§nsfw=" + nsfw + "", class="sub-to-subreddit", title="subscriptions are saved in your browser's cookies") subscribe .description p #{cleanTitle(suggested_subreddit.data.public_description)} .meta