Skip to content

Commit

Permalink
Merge pull request #1064 from hey-api/fix/client-url-encode
Browse files Browse the repository at this point in the history
fix: encode path params
  • Loading branch information
mrlubos authored Sep 19, 2024
2 parents bf76cb0 + 2079c6e commit c39ee74
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/good-clouds-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hey-api/client-axios': patch
'@hey-api/client-fetch': patch
---

fix: encode path params
4 changes: 2 additions & 2 deletions packages/client-axios/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}

url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down
4 changes: 2 additions & 2 deletions packages/client-fetch/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}

url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}

url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}

url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}
url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
continue;
}
url = url.replace(
match,
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
Expand Down

0 comments on commit c39ee74

Please sign in to comment.