From 730e6f2b1429e6c3ffb3f206397ac18ea85acbdc Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 21 Oct 2022 09:06:08 +0200 Subject: [PATCH 1/2] Make sure smhi provider api only gets a maximimum of 6 digits coordinates Fixes #2955 --- CHANGELOG.md | 1 + modules/default/weather/providers/smhi.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b26e5d55..7f16669afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Special thanks to: @rejas, @sdetweil - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated da translation - Rework weather module + - Make sure smhi provider api only gets a maximum of 6 digits coordinates (#2955) - Use fetch instead of XMLHttpRequest in weatherprovider - Reworked how weatherproviders handle units - Use unix() method for parsing times, fix suntimes on the way diff --git a/modules/default/weather/providers/smhi.js b/modules/default/weather/providers/smhi.js index bb0d2cb2e7..d8f3996832 100644 --- a/modules/default/weather/providers/smhi.js +++ b/modules/default/weather/providers/smhi.js @@ -15,8 +15,8 @@ WeatherProvider.register("smhi", { // Set the default config properties that is specific to this provider defaults: { - lat: 0, - lon: 0, + lat: 0, // Cant have more than 6 digits + lon: 0, // Cant have more than 6 digits precipitationValue: "pmedian", location: false }, @@ -104,8 +104,12 @@ WeatherProvider.register("smhi", { * @returns {string} the url for the specified coordinates */ getURL() { - let lon = this.config.lon; - let lat = this.config.lat; + const formatter = new Intl.NumberFormat("en-US", { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }); + const lon = formatter.format(this.config.lon); + const lat = formatter.format(this.config.lat); return `https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/${lon}/lat/${lat}/data.json`; }, From b8bfcb22e4e593edfbd855d8a3d3f55506de2102 Mon Sep 17 00:00:00 2001 From: veeck Date: Mon, 24 Oct 2022 20:16:10 +0200 Subject: [PATCH 2/2] Fix stupid mistake, its 6 not 2 digits --- modules/default/weather/providers/smhi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/weather/providers/smhi.js b/modules/default/weather/providers/smhi.js index d8f3996832..c3f51498a0 100644 --- a/modules/default/weather/providers/smhi.js +++ b/modules/default/weather/providers/smhi.js @@ -105,8 +105,8 @@ WeatherProvider.register("smhi", { */ getURL() { const formatter = new Intl.NumberFormat("en-US", { - minimumFractionDigits: 2, - maximumFractionDigits: 2 + minimumFractionDigits: 6, + maximumFractionDigits: 6 }); const lon = formatter.format(this.config.lon); const lat = formatter.format(this.config.lat);