feat(redirect): serve a friendly 410 page for expired links#34
Open
onamfc wants to merge 1 commit into
Open
Conversation
Expired short links previously returned the same bare 404 JSON as nonexistent ones. Now they return HTTP 410 Gone with a lightweight, unbranded 'This link has expired' page (noindex, Powered by LinkForty footer). - Distinguish expired from never-existed: when the active-link lookup misses, a secondary check finds links whose expires_at has passed — accurate even after a housekeeping job flips is_active off. - Enforce expiry on cache hits too: a link cached shortly before its expiration no longer keeps redirecting for up to the cache TTL. - Export isLinkExpired() and generateExpiredLinkHTML() with unit tests.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
expires_atreturns HTTP 410 Gone with a lightweight HTML page — clock icon, "This link has expired", one line of guidance, and a small "Powered by LinkForty" footer. Previously expired links returned the same bare404 {"error":"Link not found"}as short codes that never existed. [1]expires_athas passed (both the template-slug and legacy URL forms). Since expired links keep theirexpires_ateven after a housekeeping job deactivates them, the 410 page keeps serving indefinitely. Unknown short codes still 404. [1]expires_atafter a cache read, so links stop at the exact expiration moment. [1]noindexso expired links drop out of search engines, and it's served on whatever domain the short link uses. [1]isLinkExpired()(null/invalid timestamps fail open) andgenerateExpiredLinkHTML(), both unit-tested. [1] [2]Test plan
npm test— 145 tests pass, including new coverage forisLinkExpired(no expiry, future, past, exact-moment, unparseable) and the page content.npm run buildclean.expiresAtin the near future, click it before expiry (redirect works), after expiry (410 page), and confirm an unknown short code still returns 404.