dubinc / dub

Open-source link management infrastructure. Loved by modern marketing teams like Vercel, Raycast, and Perplexity.
https://dub.co
GNU Affero General Public License v3.0
17.49k stars 1.83k forks source link

Allow falling back to secondary (permalink) target when primary target is 404. #1059

Closed RokeJulianLockhart closed 3 weeks ago

RokeJulianLockhart commented 1 month ago

All of my links go to GitLab documents. As https://forum.gitlab.com/t/can-i-explicitly-ask-the-gitlab-web-gui-to-load-the-latest-version-of-a-file-in-the-uri/102524/3?u=rokejulianlockhart explains, because these documents may change, I use a combination of an explicit command to utilize the latest version (the HEAD - the main/master branch) and a fragment directive pointing to the heading so that if that heading changes, the match merely doesn't occur, and the document shall be presented gracefully. An example is https://dub.sh/jga, which links to /blob/HEAD/ with ?plain=0#:~:text=list%2Dstyle%2Dtype:%20none;%20%7D-,Profiles,-Table%20of%20Contents.

However, there have been instances in which the filename of the document has changed. I utilize a path naming convention which is unusually resilient to this, but it still occurs. Consequently, I would like to provide the opposite kind of URI as a fallback - versioned and pointing to specific lines, like /blob/8adbfd946684a3aa6f70b6e55322fdfda96d1eeb/ with ?plain=1#L110-753. (Note that these don't render due to a temporary issue in GitLab, but they work if you remove the fragment directive. Though, it might even be fixed by the time you see this.)

Summarily, I'd like to set a versioned URI as a fallback to my vanity URI.

linear[bot] commented 1 month ago

ENG-430 Fallback URIs when primary is 404.

steven-tey commented 3 weeks ago

This might be a bit tricky to implement in an on-demand fashion since we'll need to first make a request to see if the URL returns a 404 status code, and then fallback to the backup URL.

An alternative is to incorporate this as part of #417 (WIP) where we notify you when a URL 404s. Will close this issue for now in favor of that PR!

RokeJulianLockhart commented 3 weeks ago

https://github.com/dubinc/dub/issues/1059#issuecomment-2282362208

@steven-tey, that's a great feature, but it's not of much use to me. The reason I want this is that when I do training exercises, or am deployed somewhere, I can't respond to a URI going down. I don't believe that these should be mutually exclusive.