Encode branch in urls

This commit is contained in:
René Pfeuffer
2018-10-23 13:03:15 +02:00
parent f44f352a2a
commit df8cc25bcc
2 changed files with 5 additions and 4 deletions

View File

@@ -44,9 +44,9 @@ class Sources extends React.Component<Props> {
let url; let url;
if (branch) { if (branch) {
if (path) { if (path) {
url = `${baseUrl}/${branch.name}/${path}`; url = `${baseUrl}/${encodeURIComponent(branch.name)}/${path}`;
} else { } else {
url = `${baseUrl}/${branch.name}/`; url = `${baseUrl}/${encodeURIComponent(branch.name)}/`;
} }
} else { } else {
url = `${baseUrl}/`; url = `${baseUrl}/`;
@@ -98,6 +98,7 @@ class Sources extends React.Component<Props> {
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { repository, match } = ownProps; const { repository, match } = ownProps;
const { revision, path } = match.params; const { revision, path } = match.params;
const decodedRevision = revision ? decodeURIComponent(revision) : undefined;
const loading = isFetchBranchesPending(state, repository); const loading = isFetchBranchesPending(state, repository);
const error = getFetchBranchesFailure(state, repository); const error = getFetchBranchesFailure(state, repository);
@@ -105,7 +106,7 @@ const mapStateToProps = (state, ownProps) => {
return { return {
repository, repository,
revision, revision: decodedRevision,
path, path,
loading, loading,
error, error,

View File

@@ -39,7 +39,7 @@ function createUrl(repository: Repository, revision: string, path: string) {
// TODO handle trailing slash // TODO handle trailing slash
const pathDefined = path ? path : ""; const pathDefined = path ? path : "";
return `${base}${revision}/${pathDefined}`; return `${base}${encodeURIComponent(revision)}/${pathDefined}`;
} }
export function fetchSourcesPending( export function fetchSourcesPending(