Comfy-Org / Comfy-Org/ComfyUI_frontend
Refactor previewParam and rand to use URLSearchParams in imagePreviewStore
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Description
Currently in `src/stores/imagePreviewStore.ts`, the `getNodeImageUrls` function constructs preview URLs by mixing URLSearchParams with string concatenation:
```typescript
const params = new URLSearchParams(image)
if (isImage) appendCloudResParam(params, firstFilename)
return api.apiURL(`/view?${params}${previewParam}${rand}`)
```
The `previewParam` and `rand` parameters are appended as strings, while other parameters use the URLSearchParams API. This creates inconsistency in URL construction.
## Desired State
Refactor to add `previewParam` and `rand` values to the URLSearchParams object for consistent parameter handling:
```typescript
const params = new URLSearchParams(image)
if (isImage) appendCloudResParam(params, firstFilename)
// Add previewParam and rand to params instead of string concatenation
return api.apiURL(`/view?${params}`)
```
## Context
- Raised by @DrJKL in [PR #9298 comment](https://github.com/Comfy-Org/ComfyUI_frontend/pull/9298#discussion_r2875531769)
- Related to PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9298
- File: `src/stores/imagePreviewStore.ts`
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-9346-Refactor-previewParam-and-rand-to-use-URLSearchParams-in-imagePreviewStore-3186d73d365081aab42cd9e7807005f0) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.