mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
fix encoding and decoding for branches including slashes
This commit is contained in:
@@ -53,7 +53,7 @@ class Sources extends React.Component<Props, State> {
|
||||
const { fetchBranches, repository, revision, path, fetchSources } = this.props;
|
||||
|
||||
fetchBranches(repository);
|
||||
fetchSources(repository, revision, path);
|
||||
fetchSources(repository, this.decodeRevision(revision), path);
|
||||
|
||||
this.redirectToDefaultBranch();
|
||||
}
|
||||
@@ -61,12 +61,16 @@ class Sources extends React.Component<Props, State> {
|
||||
componentDidUpdate(prevProps) {
|
||||
const { fetchSources, repository, revision, path } = this.props;
|
||||
if (prevProps.revision !== revision || prevProps.path !== path) {
|
||||
fetchSources(repository, revision, path);
|
||||
fetchSources(repository, this.decodeRevision(revision), path);
|
||||
}
|
||||
|
||||
this.redirectToDefaultBranch();
|
||||
}
|
||||
|
||||
decodeRevision = (revision: string) => {
|
||||
return revision ? decodeURIComponent(revision) : revision;
|
||||
};
|
||||
|
||||
redirectToDefaultBranch = () => {
|
||||
const { branches } = this.props;
|
||||
if (this.shouldRedirectToDefaultBranch()) {
|
||||
@@ -171,7 +175,7 @@ class Sources extends React.Component<Props, State> {
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { repository, match } = ownProps;
|
||||
const { revision, path } = match.params;
|
||||
const decodedRevision = revision ? decodeURIComponent(revision) : revision;
|
||||
const decodedRevision = revision ? decodeURIComponent(revision) : undefined;
|
||||
const loading = isFetchBranchesPending(state, repository);
|
||||
const error = getFetchBranchesFailure(state, repository);
|
||||
const branches = getBranches(state, repository);
|
||||
@@ -198,7 +202,7 @@ const mapDispatchToProps = dispatch => {
|
||||
dispatch(fetchBranches(repository));
|
||||
},
|
||||
fetchSources: (repository: Repository, revision: string, path: string) => {
|
||||
dispatch(fetchSources(repository, decodeURIComponent(revision), path));
|
||||
dispatch(fetchSources(repository, revision, path));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,10 +16,10 @@ export function fetchSources(repository: Repository, revision: string, path: str
|
||||
.get(createUrl(repository, revision, path))
|
||||
.then(response => response.json())
|
||||
.then(sources => {
|
||||
dispatch(fetchSourcesSuccess(repository, decodeURIComponent(revision), path, sources));
|
||||
dispatch(fetchSourcesSuccess(repository, revision, path, sources));
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch(fetchSourcesFailure(repository, decodeURIComponent(revision), path, err));
|
||||
dispatch(fetchSourcesFailure(repository, revision, path, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user