fix(web): Encode parenthesis in query params (#674)

This commit is contained in:
Brendan Kellam 2025-12-12 13:53:30 -08:00 committed by GitHub
parent 58ba6e8c1a
commit dcb7ba66ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- 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)
## [4.10.3] - 2025-12-12 ## [4.10.3] - 2025-12-12
### Fixed ### Fixed

View file

@ -62,10 +62,18 @@ export const createPathWithQueryParams = (path: string, ...queryParams: [string,
return path; return path;
} }
const queryString = queryParams.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value ?? '')}`).join('&'); const queryString = queryParams.map(([key, value]) => `${encodeURIComponent(key)}=${encodeRFC3986URIComponent(value ?? '')}`).join('&');
return `${path}?${queryString}`; return `${path}?${queryString}`;
} }
// @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
const encodeRFC3986URIComponent = (str: string) => {
return encodeURIComponent(str).replace(
/[!'()*]/g,
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
);
}
type AuthProviderInfo = { type AuthProviderInfo = {
id: string; id: string;
name: string; name: string;