Skip to content

Commit

Permalink
fix(url): add extra level of URI encode on url to preserve image src …
Browse files Browse the repository at this point in the history
…query
  • Loading branch information
Josh-McFarlin committed Feb 13, 2022
1 parent dd4b4b6 commit 8fe5e60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Added extra level of URI encode on url to preserve image src query

## [0.3.3] - 2022-02-13

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/responsiveImage/responsiveImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useResponsiveImage = (

for (const { size } of responsive) {
const srcSetUrl = encodeQuery(loaderUrl, {
src: image.src,
src: encodeURI(image.src || ""),
width: size.width,
height: size.height,
...options,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const encodeQuery = (url: string, query: Record<string, any>): string =>
{
skipNull: true,
arrayFormat: "bracket",
sort: false,
}
);

Expand All @@ -27,6 +28,7 @@ export const decodeTransformQuery = (
arrayFormat: "bracket",
parseNumbers: true,
parseBooleans: true,
sort: false,
});

export const parseURL = (rawUrl: string, baseUrl?: URL | string): URL => {
Expand Down

0 comments on commit 8fe5e60

Please sign in to comment.