Skip to content

Commit aa6a722

Browse files
committed
fix(explorer): encode RFC 3986 reserved chars in query parameter values
Replaces the manual space-only encoding with encodeURIComponent for query parameters, so reserved characters like ':' are correctly percent-encoded (e.g. ':' → '%3A') when building request URLs. Path parameters retain the existing whitespace-only encoding since they are handled separately downstream in setPathParams. Closes #1312
1 parent ba1f51d commit aa6a722

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ export default function ParamTextFormItem({
3838
setParam({
3939
...param,
4040
value:
41-
param.in === "path" || param.in === "query"
41+
param.in === "path"
4242
? e.target.value.replace(/\s/g, "%20")
43-
: e.target.value,
43+
: param.in === "query"
44+
? encodeURIComponent(e.target.value)
45+
: e.target.value,
4446
})
4547
)
4648
}

0 commit comments

Comments
 (0)