Solved: It turns out I needed to add https:// to the redirect URL. I now edited the redirect to be this:

{
    "createdBy": "Redirector v3.5.3",
    "createdAt": "2024-12-25T00:25:04.487Z",
    "redirects": [
        {
            "description": "sh.reddit.com submission page",
            "exampleUrl": "https://old.reddit.com/r/firefox/submit?selftext=true",
            "exampleResult": "https://sh.reddit.com/r/firefox/submit?selftext=true",
            "error": null,
            "includePattern": "https://.*?reddit.com/((r|u|user)/.*?/submit.*)",
            "excludePattern": "",
            "patternDesc": "",
            "redirectUrl": "https://sh.reddit.com/$1",
            "patternType": "R",
            "processMatches": "noProcessing",
            "disabled": false,
            "grouped": false,
            "appliesTo": [
                "main_frame"
            ]
        }, 
    ]
}

Using the Redirector addon, I wrote a redirect from a Reddit submit page to the new new Reddit submit page but it doesn’t work when I go to https://old.reddit.com/r/firefox/ and click “submit text”, it just takes me to https://old.reddit.com/r/firefox/submit?selftext=true despite the link working in the example box.

Reproduction: Install the addon, save the following as a json file, click on addon icons and select “edit redirects”, then click import to select the json file.

{
"createdBy": "Redirector v3.5.3",
"createdAt": "2024-12-22T15:43:42.356Z",
"redirects": [
{
"description": "sh.reddit.com submission page",
"exampleUrl": "https://old.reddit.com/r/tds_roblox/submit",
"exampleResult": "sh.reddit.com/r/tds_roblox/submit",
"error": null,
"includePattern": "[a-z]+?:\\/\\/.+?reddit.com\\/((r|u|user)\\/.+?\\/submit.*?$)",
"excludePattern": "",
"patternDesc": "",
"redirectUrl": "sh.reddit.com/$1",
"patternType": "R",
"processMatches": "noProcessing",
"disabled": false,
"grouped": false,
"appliesTo": [
"main_frame"
]
},
{
"description": "Old Reddit",
"exampleUrl": "https://www.reddit.com/r/reddit",
"exampleResult": "https://old.reddit.com/r/reddit",
"error": null,
"includePattern": "[a-z]+?:\\/\\/.*?\\.reddit\\.com\\/(((r|u|user)\\/.*)|$)",
"excludePattern": "[a-z]+?:\\/\\/.+?reddit.com\\/((r|u|user)\\/.+?\\/submit.*?$)",
"patternDesc": "",
"redirectUrl": "https://old.reddit.com/$1",
"patternType": "R",
"processMatches": "noProcessing",
"disabled": false,
"grouped": false,
"appliesTo": [
"main_frame"
]
}
]
}
  • kbal
    link
    fedilink
    119 days ago

    Dunno, but I’d start by removing the “?$” from your regexes unless there’s a good reason not to. It’s confusing to me and might be to the parser as well. There’s also no need to escape the “/”.

    If the “?” is there because you’re trying to require a literal ? in the url, you do need to escape that. But then it wouldn’t normally make sense to have the $ immediately after it. “*?” isn’t meaningful as a pattern quantity or whatever it’s called: * already implies ?.

    • @TheTwelveYearOldOP
      link
      English
      019 days ago

      I changed the pattern to https://.+?reddit.com/((r|u|user)/.*?/submit.*$) and it still doesn’t work.

      • kbal
        link
        fedilink
        118 days ago

        Ah well, at least that’s easier to read. +? and *? are weird although I wouldn’t expect them to break things in a way that matches what you see happening. They can both be replaced with just *. + means at least one, ? means zero or one, * means zero or more.