honestbleeps / Reddit-Enhancement-Suite

Reddit Enhancement Suite
http://redditenhancementsuite.com
GNU General Public License v3.0
4.13k stars 881 forks source link

EscapeNP turns up a malformed URL when using the subreddit bar from an NP link #2919

Open kevinulrich opened 8 years ago

kevinulrich commented 8 years ago

I'm not sure whether this has just recently started happening. I've looked around open issues and couldn't find this exact symptom - wondering if i may be alone with this?

When i visit an NP link like this one from the frontpage and from then on use my subreddit bar for navigation, i will arrive on a malformed URL which obviously doesn't work. For example /r/aviation will turn into: https://np.reddit.comhttps//www.reddit.com/r/aviation.

This will only happen when EscapeNP is on and only if i open the link in the current tab. Opening the link in a new tab or window will prevent this from happening and EscapeNP will work as it should - the href is correct.

I am using version 4.6.1 on Firefox 45.0.2

erikdesjardins commented 8 years ago

I can't reproduce this, although I have seen a few reports.

IIRC one of them was caused by another extension which was rewriting the URL at the same time as RES' escapeNp -- does it still happen if you disable everything except RES?

kevinulrich commented 8 years ago

Yes, just checked. All Addons disabled except RES, still the same problem. I just dove into the code a bit and figured this might be the problem:

function followSubredditShortcut() {
    if (BrowserDetect.isFirefox()) {
        // stupid firefox... sigh...
        location.href = `${location.protocol}//${location.hostname}${clickedShortcut}`;
    } else {
        location.href = clickedShortcut;
    }
}

clickedShortcut contains the original link href, which is already an absolute URL. Whatever made you do that FF-fix in the past seems to be gone :)

jewel-andraia commented 8 years ago

@kevinulrich FYI you are looking at master (future release) when what you're actually running is in the release/4.6.1 branch: https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/release/4.6.1/lib/modules/subredditManager.js#L738

followSubredditShortcut: function() {
        if (BrowserDetect.isFirefox()) {
            // stupid firefox... sigh...
            location.href = location.protocol + '//' + location.hostname + modules['subredditManager'].clickedShortcut;
        } else {
            location.href = modules['subredditManager'].clickedShortcut;
        }
    },