Reddit-Enhancement-Suite icon indicating copy to clipboard operation
Reddit-Enhancement-Suite copied to clipboard

Multi-reddit navbar links are broken

Open Kushagra-0801 opened this issue 8 months ago • 0 comments

  • My browser (copy from https://www.whatismybrowser.com): Firefox on Windows 10
  • My RES version: 5.24.6
  • Am I in reddit beta (yes/no): no

What's the problem? The multi-reddit navbar links are broken.

Are there any related posts in https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues or /r/RESissues? Couldn't find any.

What other browser extensions are installed? Ublock Origin and a few more unrelated ones.

Possible root cause In file (https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/bfbceb27cd1a3eeebc48c0704d50cabc8a4a417d/lib/modules/multiredditNavbar.js#L43) the values are given as relative paths (./ prepended).

These are directly appended to the base url of the multi reddit (https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/bfbceb27cd1a3eeebc48c0704d50cabc8a4a417d/lib/modules/multiredditNavbar.js#L106), leading to broken links.

Suggestion

Use the following fragment for creating the element:

const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
const fullUrl = (new URL(url, normalizedBaseUrl)).href;
const li = string.html`<li><a href="${fullUrl}">${label}</a></li>`;

I would have made a PR but I do not have the setup on my laptop for running code.

Kushagra-0801 avatar May 31 '24 09:05 Kushagra-0801