diff --git a/components/x-teaser/src/Image.jsx b/components/x-teaser/src/Image.jsx index 3c02bacc8..3a430a0aa 100644 --- a/components/x-teaser/src/Image.jsx +++ b/components/x-teaser/src/Image.jsx @@ -46,4 +46,4 @@ export default ({ relativeUrl, url, image, imageSize, imageLazyLoad, imageHighes ) : null; -}; +}; \ No newline at end of file diff --git a/components/x-teaser/src/concerns/image-service.js b/components/x-teaser/src/concerns/image-service.js index cf42141d3..18f46d5a4 100644 --- a/components/x-teaser/src/concerns/image-service.js +++ b/components/x-teaser/src/concerns/image-service.js @@ -1,4 +1,3 @@ -const { URL, URLSearchParams } = require('url'); const BASE_URL = 'https://www.ft.com/__origami/service/image/v2/images/raw'; const OPTIONS = { source:'next', fit:'scale-down', dpr:2 }; @@ -9,8 +8,10 @@ const OPTIONS = { source:'next', fit:'scale-down', dpr:2 }; * @param {String} options */ export default function imageService(url, width, options) { - const imageSrc = new URL(`${BASE_URL}/${encodeURIComponent(url)}`); - imageSrc.search = new URLSearchParams({...OPTIONS, ...options }); - imageSrc.searchParams.set('width', width); - return imageSrc.href; + + const imageOptions = {...OPTIONS, ...options, width }; + const encoded = encodeURIComponent(url); + const optionsEncoded = Object.entries(imageOptions).map(([key,value],i)=>`${(i?'&':'')}${key}=${value}`).join(''); + const href = `${BASE_URL}/${encoded}?${optionsEncoded}`; + return href; } diff --git a/package.json b/package.json index 60e22cc16..a0502a24e 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "eslint-plugin-react": "^7.13.0", "fetch-mock": "^7.3.3", "jest": "^24.8.0", - "node-sass": "^4.12.0", + "node-sass": "^4.14.1", "react": "^16.8.6", "react-helmet": "^5.2.0", "react-test-renderer": "^16.8.6",