@@ -68,6 +68,22 @@ export const redirectToAppStore = ({
6868 ) ;
6969} ;
7070
71+ const redirectToExtensionStore = (
72+ req : FastifyRequest ,
73+ res : FastifyReply ,
74+ ) : FastifyReply => {
75+ const ua = uaParser ( req . headers [ 'user-agent' ] ) ;
76+ const browser = ua . browser . name ?. toLowerCase ( ) ;
77+ const url = new URL ( req . raw . url ! , 'http://localhost' ) ;
78+ res . status ( 307 ) ;
79+
80+ const redirectURL = browser ?. includes ( 'edge' )
81+ ? `https://microsoftedge.microsoft.com/addons/detail/daily-20-source-for-bu/cbdhgldgiancdheindpekpcbkccpjaeb${ url . search } `
82+ : `https://chrome.google.com/webstore/detail/daily-discover-web-techno/jlmpjdjjbgclbocgajdjefcidcncaied${ url . search } ` ;
83+
84+ return res . status ( 307 ) . redirect ( redirectURL ) ;
85+ } ;
86+
7187const redirectToStore =
7288 ( con : DataSource ) =>
7389 async ( req : FastifyRequest , res : FastifyReply ) : Promise < FastifyReply > => {
@@ -103,15 +119,7 @@ const redirectToStore =
103119 return res . redirect ( `https://app.daily.dev${ url . search } ` ) ;
104120 }
105121
106- if ( browser ?. includes ( 'edge' ) ) {
107- return res . redirect (
108- `https://microsoftedge.microsoft.com/addons/detail/daily-20-source-for-bu/cbdhgldgiancdheindpekpcbkccpjaeb${ url . search } ` ,
109- ) ;
110- }
111-
112- return res . redirect (
113- `https://chrome.google.com/webstore/detail/daily-discover-web-techno/jlmpjdjjbgclbocgajdjefcidcncaied${ url . search } ` ,
114- ) ;
122+ return redirectToExtensionStore ( req , res ) ;
115123 } ;
116124
117125const redirectToMobile =
@@ -173,6 +181,7 @@ export default async function (fastify: FastifyInstance): Promise<void> {
173181 ) ;
174182 fastify . get ( '/download' , redirectToStore ( con ) ) ;
175183 fastify . get ( '/get' , redirectToStore ( con ) ) ;
184+ fastify . get ( '/get-extension' , redirectToExtensionStore ) ;
176185 fastify . get ( '/mobile' , redirectToMobile ( con ) ) ;
177186 fastify . get < { Params : { id : string } } > ( '/:id/profile-image' , ( req , res ) =>
178187 redirectToProfileImage ( con , res , req . params . id ) ,
0 commit comments