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
This commit is contained in:
gmnsii 2023-03-23 12:36:04 -07:00
parent a0726c5903
commit 8be69f6fe5

View file

@ -899,7 +899,7 @@ pub fn should_be_nsfw_gated(req: &Request<Body>, 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
}