mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 12:55:19 +00:00
fix(web): Fix error when navigating to paths with percent symbols (#485)
* fix * changelog
This commit is contained in:
parent
2241217b0b
commit
d4cb532e40
4 changed files with 23 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
- Remove setting `remote.origin.url` for remote git repositories. [#483](https://github.com/sourcebot-dev/sourcebot/pull/483)
|
||||
- Fix error when navigating to paths with percentage symbols. [#485](https://github.com/sourcebot-dev/sourcebot/pull/485)
|
||||
|
||||
### Changed
|
||||
- Updated NextJS to version 15. [#477](https://github.com/sourcebot-dev/sourcebot/pull/477)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default async function BrowsePage(props: BrowsePageProps) {
|
|||
domain
|
||||
} = params;
|
||||
|
||||
const rawPath = decodeURIComponent(_rawPath.join('/'));
|
||||
const rawPath = _rawPath.join('/');
|
||||
const { repoName, revisionName, path, pathType } = getBrowseParamsFromPathParam(rawPath);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -98,6 +98,26 @@ describe('getBrowseParamsFromPathParam', () => {
|
|||
pathType: 'blob',
|
||||
});
|
||||
});
|
||||
|
||||
it('should decode paths with percent symbols in path', () => {
|
||||
const result = getBrowseParamsFromPathParam('github.com/sourcebot-dev/zoekt@HEAD/-/blob/%25hello%25%2Fworld.c');
|
||||
expect(result).toEqual({
|
||||
repoName: 'github.com/sourcebot-dev/zoekt',
|
||||
revisionName: 'HEAD',
|
||||
path: '%hello%/world.c',
|
||||
pathType: 'blob',
|
||||
});
|
||||
});
|
||||
|
||||
it('should decode paths with @ symbol encoded', () => {
|
||||
const result = getBrowseParamsFromPathParam('github.com/sourcebot-dev/zoekt%40HEAD/-/blob/file.txt');
|
||||
expect(result).toEqual({
|
||||
repoName: 'github.com/sourcebot-dev/zoekt',
|
||||
revisionName: 'HEAD',
|
||||
path: 'file.txt',
|
||||
pathType: 'blob',
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('different revision formats', () => {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const getBrowseParamsFromPathParam = (pathParam: string) => {
|
|||
throw new Error(`Invalid browse pathname: "${pathParam}" - expected to contain "/-/(tree|blob)/" pattern`);
|
||||
}
|
||||
|
||||
const repoAndRevisionPart = pathParam.substring(0, sentinelIndex);
|
||||
const repoAndRevisionPart = decodeURIComponent(pathParam.substring(0, sentinelIndex));
|
||||
const lastAtIndex = repoAndRevisionPart.lastIndexOf('@');
|
||||
|
||||
const repoName = lastAtIndex === -1 ? repoAndRevisionPart : repoAndRevisionPart.substring(0, lastAtIndex);
|
||||
|
|
|
|||
Loading…
Reference in a new issue