Skip to content

Commit

Permalink
fix: Decode spaces in factory url (#976)
Browse files Browse the repository at this point in the history
* fix: Encode spaces in factory url

Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored Nov 9, 2023
1 parent 4e2738d commit 5fb409d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ kubectl rollout restart deployment/che-operator -n $CHE_NAMESPACE

Currently, Dashboard uses the following che-server API:

| Method | Path |
|--------|-------------------------------------|
| POST | /kubernetes/namespace/provision |
| GET | /kubernetes/namespace |
| POST | /factory/resolver/ |
| POST | /factory/token/refresh |
| GET | /oauth |
| GET | /oauth/token |
| DELETE | /oauth/token |
| Method | Path |
|--------|---------------------------------|
| POST | /kubernetes/namespace/provision |
| GET | /kubernetes/namespace |
| POST | /factory/resolver/ |
| POST | /factory/token/refresh |
| GET | /oauth |
| GET | /oauth/token |
| DELETE | /oauth/token |
| GET | /scm/resolve |


# Builds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export async function getFactoryResolver(
url: string,
overrideParams: { [params: string]: string } = {},
): Promise<FactoryResolver> {
if (url.indexOf(' ') !== -1) {
url = encodeURI(url);
}
const response = await axios.post(
`${cheServerPrefix}/factory/resolver`,
Object.assign({}, overrideParams, { url }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ export async function grabLink(
}

const url = new URL(foundLink.href);
let search = '?';
url.searchParams.forEach((value, key) => {
search += `${key}=${encodeURIComponent(encodeURI(value))}&`;
});
search = search.slice(0, -1);

try {
// load it in raw format
// see https://github.com/axios/axios/issues/907
const response = await axios.get<string>(`${url.pathname}${url.search}`, {
const response = await axios.get<string>(`${url.pathname}${search}`, {
responseType: 'text',
transformResponse: [
data => {
Expand Down

0 comments on commit 5fb409d

Please sign in to comment.