Skip to content

Commit

Permalink
Merge pull request #4120 from thematters/fix/prod-sign-up-link
Browse files Browse the repository at this point in the history
[hotfix - master] fix: fix signupCallbackUrl
  • Loading branch information
robertu7 authored Jan 8, 2024
2 parents dab612c + 1260242 commit 3157e91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/common/utils/oauth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ describe('utils/oauth', () => {
vi.stubEnv('NEXT_PUBLIC_SITE_DOMAIN', 'web-dev.matters.town')

it('should get signupCallbackUrl correctly', () => {
expect(signupCallbackUrl('email', 'code')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=email&referral=code'
expect(signupCallbackUrl('[email protected]', 'code')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=test%2Babc%40matters.news&referral=code'
)
expect(signupCallbackUrl('email')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=email'
Expand Down
6 changes: 2 additions & 4 deletions src/common/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ export const signupCallbackUrl = (email: string, referralCode?: string) => {
return `https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/callback/${
CALLBACK_PROVIDERS.EmailSignup
}?${new URLSearchParams({
email: encodeURIComponent(email),
...(referralCode
? { [REFERRAL_QUERY_REFERRAL_KEY]: encodeURIComponent(referralCode) }
: null),
email,
...(referralCode ? { [REFERRAL_QUERY_REFERRAL_KEY]: referralCode } : null),
}).toString()}`
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/Hook/useRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PATHS } from '~/common/enums'
import { useRoute } from './useRoute'

beforeEach(() => {
mockRouter.push(PATHS.ABOUT + '?name=foo')
mockRouter.push(PATHS.ABOUT + '?name=foo&email=test%2Babc%40matters.news')
})

describe('components/Hook/useRoute', () => {
Expand All @@ -26,6 +26,7 @@ describe('components/Hook/useRoute', () => {
it('should return query value by key', () => {
const { result } = renderHook(() => useRoute())
expect(result.current.getQuery('name')).toBe('foo')
expect(result.current.getQuery('email')).toBe('[email protected]')
expect(result.current.getQuery('mediaHash')).toBe('')
})

Expand Down

0 comments on commit 3157e91

Please sign in to comment.