sblask-webextensions / webextension-skip-redirect

Some web pages use intermediary pages before redirecting to a final page. This add-on tries to extract the final url from the intermediary url and goes there straight away if successful.
https://addons.mozilla.org/firefox/addon/skip-redirect/
MIT License
489 stars 45 forks source link

Redirect Postmark #277

Closed adriaandotcom closed 2 years ago

adriaandotcom commented 2 years ago

New Issue Checklist (tick off like this: [x])

What is your browser?

What is your operating system?

Description (please include examples/screenshots where applicable)

postmarkapp.com is using a shortener that has this format:

https://click.pstmrk.it/2sm/my.paddle.com%2Freceipt%2F00000000-00000000%2F00000000-aaaaa0aa000aa00-000aa00a0a/AaaAAAaA/0aA/aAAAaa0AA0/a0Aaa0AaaAA0aA0aA0AAA0AaaAA

It contains all data needed for a redirect, in this case, the page redirects to:

https://my.paddle.com/invoice/00000000-00000000/00000000-aaaaa0aa000aa00-000aa00a0a

I couldn't find in the source code if this is easy to implement, but something like this could work:

const url = "https://click.pstmrk.it/2sm/my.paddle.com%2Freceipt%2F00000000-00000000%2F00000000-aaaaa0aa000aa00-000aa00a0a/AaaAAAaA/0aA/aAAAaa0AA0/a0Aaa0AaaAA0aA0aA0AAA0AaaAA" 
const matches = url.match(/https:\/\/click\.pstmrk\.it\/[a-z0-9]+\/([^/]+)/i);
const redirect = matches[1] ? "http://" + decodeURIComponent(matches[1]) : null;
sblask commented 2 years ago

These would be the places responsible for URLs that are part of the path:

https://github.com/sblask/webextension-skip-redirect/blob/main/url.js#L45 https://github.com/sblask/webextension-skip-redirect/blob/main/url.js#L25

As you can see only very general rules are supported, some protocols and www. No way to support your use case.

adriaandotcom commented 2 years ago

It's unfortunate it's not possible. But thanks for getting back to me. Appriciated.