diff --git a/__tests__/redirector.ts b/__tests__/redirector.ts index 68de111f0a..95bb0c8737 100644 --- a/__tests__/redirector.ts +++ b/__tests__/redirector.ts @@ -42,14 +42,14 @@ describe('GET /r/:postId', () => { return request(app.server) .get('/r/p1') .expect(302) - .expect('Location', 'http://p1.com/?ref=dailydev'); + .expect('Location', 'http://p1.com/?via=dailydev'); }); it('should redirect to youtube post url', () => { return request(app.server) .get('/r/yt1') .expect(302) - .expect('Location', 'https://youtu.be/T_AbQGe7fuU?ref=dailydev'); + .expect('Location', 'https://youtu.be/T_AbQGe7fuU?via=dailydev'); }); it('should render redirect html and notify view event', async () => { @@ -61,9 +61,9 @@ describe('GET /r/:postId', () => { .expect(200) .expect('content-type', 'text/html') .expect('referrer-policy', 'origin, origin-when-cross-origin') - .expect('link', `; rel="preconnect"`) + .expect('link', `; rel="preconnect"`) .expect( - '', + '', ); expect(notifyView).toBeCalledWith( expect.anything(), @@ -82,9 +82,9 @@ describe('GET /r/:postId', () => { .expect(200) .expect('content-type', 'text/html') .expect('referrer-policy', 'origin, origin-when-cross-origin') - .expect('link', `; rel="preconnect"`) + .expect('link', `; rel="preconnect"`) .expect( - '', + '', ); }); @@ -95,7 +95,7 @@ describe('GET /r/:postId', () => { return request(app.server) .get('/r/p1') .expect(302) - .expect('Location', 'http://p1.com/?a=b&ref=dailydev'); + .expect('Location', 'http://p1.com/?a=b&via=dailydev'); }); it('should redirect to post page when url is not available', async () => { @@ -118,7 +118,7 @@ describe('GET /r/:postId', () => { .expect(302) .expect( 'Location', - 'http://p1.com/hello%20world/%f0%9f%9a%80-to-the-%F0%9F%8C%94?ref=dailydev', + 'http://p1.com/hello%20world/%f0%9f%9a%80-to-the-%F0%9F%8C%94?via=dailydev', ); }); }); diff --git a/src/routes/redirector.ts b/src/routes/redirector.ts index 191b59c0e6..feed1a2a4b 100644 --- a/src/routes/redirector.ts +++ b/src/routes/redirector.ts @@ -35,7 +35,7 @@ export default async function (fastify: FastifyInstance): Promise { return res.status(302).redirect(getDiscussionLink(post.slug)); } const url = new URL(post.url); - url.searchParams.append('ref', 'dailydev'); + url.searchParams.append('via', 'dailydev'); const encodedUri = encodeUrl(url.href); if (req.isBot) { return res.status(302).redirect(encodedUri);