Skip to content

Commit f35960e

Browse files
committed
fix: generateId url safe
1 parent d6021c5 commit f35960e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/utils/encoding.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export const generateId = (source: string) => {
1515
idString += `?${firstParam[0]}=${firstParam[1]}`;
1616
}
1717

18-
return Buffer.from(idString).toString('base64');
18+
return encodeURIComponent(Buffer.from(idString).toString('base64'));
1919
};
2020

2121
export const getSourceFromId = (id: string) => {
22-
const decoded = Buffer.from(id, 'base64').toString('utf8');
22+
const decoded = decodeURIComponent(Buffer.from(id, 'base64').toString('utf8'));
2323

2424
return `https://${decoded}`;
2525
};

tests/integration/search/podcast.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('GET /search - Podcast Episode', () => {
6464
const response = await app.handle(request).then(res => res.json());
6565

6666
expect(response).toEqual({
67-
id: 'b3Blbi5zcG90aWZ5LmNvbS9lcGlzb2RlLzQzVENyZ21QMjNxa0xjQVhaUU44cVQ=',
67+
id: 'b3Blbi5zcG90aWZ5LmNvbS9lcGlzb2RlLzQzVENyZ21QMjNxa0xjQVhaUU44cVQ%3D',
6868
type: 'podcast',
6969
title: 'The End of Twitter as We Know It',
7070
description:

tests/integration/search/spotify-exculsive.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('GET /search - Spotify Exclusive Content', () => {
6767
const response = await app.handle(request).then(res => res.json());
6868

6969
expect(response).toEqual({
70-
id: 'b3Blbi5zcG90aWZ5LmNvbS9zaG93LzdMdVF2NDAwSkZ6emxKck91TXVrUmo=',
70+
id: 'b3Blbi5zcG90aWZ5LmNvbS9zaG93LzdMdVF2NDAwSkZ6emxKck91TXVrUmo%3D',
7171
type: 'show',
7272
title: 'The Louis Theroux Podcast',
7373
description:

0 commit comments

Comments
 (0)