Skip to content

Commit dcb7ba6

Browse files
fix(web): Encode parenthesis in query params (#674)
1 parent 58ba6e8 commit dcb7ba6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed issue where parenthesis in query params were not being encoded, resulting in a poor experience when embedding links in Markdown. [#674](https://github.com/sourcebot-dev/sourcebot/pull/674)
12+
1013
## [4.10.3] - 2025-12-12
1114

1215
### Fixed

packages/web/src/lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ export const createPathWithQueryParams = (path: string, ...queryParams: [string,
6262
return path;
6363
}
6464

65-
const queryString = queryParams.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value ?? '')}`).join('&');
65+
const queryString = queryParams.map(([key, value]) => `${encodeURIComponent(key)}=${encodeRFC3986URIComponent(value ?? '')}`).join('&');
6666
return `${path}?${queryString}`;
6767
}
6868

69+
// @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
70+
const encodeRFC3986URIComponent = (str: string) => {
71+
return encodeURIComponent(str).replace(
72+
/[!'()*]/g,
73+
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
74+
);
75+
}
76+
6977
type AuthProviderInfo = {
7078
id: string;
7179
name: string;

0 commit comments

Comments
 (0)