Skip to content

Commit

Permalink
fix: correctly generate url params for sanity images
Browse files Browse the repository at this point in the history
closes #63
  • Loading branch information
danielroe committed Jan 16, 2021
1 parent 8f0cbaf commit cb9c223
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/sanity-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const SanityImage = extendVue({

const queryParams = keys
.map((prop) => {
const urlFormat = prop.replace(/[A-Z]./, r => '-' + r[1].toLowerCase())
const urlFormat = prop.replace(/[A-Z]/, r => '-' + r.toLowerCase())
return props[prop] ? `${urlFormat}=${props[prop]}` : undefined
})
.filter(Boolean)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/__snapshots__/sanity-image.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SanityImage provides a valid renderless component 1`] = `<img src="https://cdn.sanity.io/images/undefined/production/G3i4emG6B8JnTmGoN0UjgAp8-300x450.jpg?auto=format">`;
exports[`SanityImage provides a valid renderless component 1`] = `<img src="https://cdn.sanity.io/images/undefined/production/G3i4emG6B8JnTmGoN0UjgAp8-300x450.jpg?auto=format&amp;fp-x=0.5">`;
1 change: 1 addition & 0 deletions test/unit/sanity-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('SanityImage', () => {
<SanityImage
asset-id="image-G3i4emG6B8JnTmGoN0UjgAp8-300x450-jpg"
auto="format"
:fp-x="0.5"
>
<template #default="{ src }">
<img :src="src" />
Expand Down

0 comments on commit cb9c223

Please sign in to comment.