From 8be69f6fe5a99acdec053eef9871a3d1a2f035ce Mon Sep 17 00:00:00 2001 From: gmnsii Date: Thu, 23 Mar 2023 12:36:04 -0700 Subject: [PATCH] Checks if the link contains the parameter instead of ends with it To know if the gate should be bypassed, we check if the link contains the pasameter instead of checking if the link ends with it. This is impostant, for example if we were to implement searching for comments within a post. If we wanted to search for comments within a post that we have bypassed the gate to view: the link will look like https://libreddit-instance/r/somesub/comments/post-id/post-title&bypass_nsfw_landing/?q=some-query&type=comment --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 3290eab..172bf4d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -899,7 +899,7 @@ pub fn should_be_nsfw_gated(req: &Request, req_url: &String) -> bool { let gate_nsfw = (setting(&req, "show_nsfw") != "on") || sfw_instance; // Nsfw landing gate should not be bypassed on a sfw only instance, - let bypass_gate = !sfw_instance && req_url.ends_with("&bypass_nsfw_landing"); + let bypass_gate = !sfw_instance && req_url.contains("&bypass_nsfw_landing"); gate_nsfw && !bypass_gate }