diff --git a/scripts/workers-site/index.js b/scripts/workers-site/index.js index 0a24b923c6..737b50f020 100644 --- a/scripts/workers-site/index.js +++ b/scripts/workers-site/index.js @@ -29,21 +29,6 @@ function checkIsBot(val) { } async function handleEvent(event) { - // One-off fix for old-style route shared on twitter - // We don't make old-style routes anymore but older mobile app versions generate bad links - // TODO: Remove this and make old style routes for a while longer until user sediment updates - if ( - event.request.url.endsWith( - 'hannibalburess/coach-wilson-produced-by-flux-pavilion-517598' - ) - ) { - const newUrl = event.request.url.substring( - 0, - event.request.url.length - '-517598'.length - ) - return Response.redirect(newUrl, 301) - } - const url = new URL(event.request.url) const { pathname, search, hash } = url const userAgent = event.request.headers.get('User-Agent') || '' diff --git a/src/services/audius-api-client/AudiusAPIClient.ts b/src/services/audius-api-client/AudiusAPIClient.ts index f85de61f31..42144efc21 100644 --- a/src/services/audius-api-client/AudiusAPIClient.ts +++ b/src/services/audius-api-client/AudiusAPIClient.ts @@ -712,7 +712,19 @@ class AudiusAPIClient { args, true ) - if (!trackResponse) return null + // Try the old route method, ensuring that the track once found has the same owner handle + // Ensure at least 5 digits (anything lower has old route in the DB) + if (!trackResponse) { + const matches = args.slug.match(/[0-9]{5,}$/) + if (!matches) return null + const oldTrackResponse = await this.getTrack({ + id: parseInt(matches[0]) + }) + if (!oldTrackResponse || oldTrackResponse.user.handle !== args.handle) { + return null + } + return oldTrackResponse + } return adapter.makeTrack(trackResponse.data) }