From 0b78a33dfb4b30ea0e393de37ed7bf169d379f57 Mon Sep 17 00:00:00 2001 From: Anthony Roach Date: Thu, 18 Feb 2021 09:52:01 -0500 Subject: [PATCH] Fixed a url parsing bug Fixed a url parsing bug exposed by the newest url-parse module which caused the URL passed to the lambda to be missing a leading forward slash. --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/adapters/helpers/lambdaEvent.js | 3 ++- yarn.lock | 8 ++++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3335a5d..01e42da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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). +## [1.4.1] - 2020-02-18 +### Fixed +- Fixed a url parsing bug exposed by the newest url-parse module which caused +the URL passed to the lambda to be missing a leading forward slash. + ## [1.3.1] - 2020-11-12 ### Fixed - Move away from module declarations due to limitations (cannot export types diff --git a/package.json b/package.json index 491c5d7..6d8a28e 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "lodash": "^4.17.20", "nearley": "^2.19.7", "resolve-pathname": "^3.0.0", - "url-parse": "^1.4.7" + "url-parse": "^1.5.0" }, "publishConfig": { "access": "public" diff --git a/src/adapters/helpers/lambdaEvent.js b/src/adapters/helpers/lambdaEvent.js index ce1d43d..39cae2f 100644 --- a/src/adapters/helpers/lambdaEvent.js +++ b/src/adapters/helpers/lambdaEvent.js @@ -2,7 +2,8 @@ const urlParse = require('url-parse'); const querystring = require('querystring'); module.exports = (config, relativeUrl) => { - const parts = urlParse(relativeUrl || config.url, null, querystringWithArraySupport); + // url-parse needs a location to properly handle relative urls, so provide a fake one here: + const parts = urlParse(relativeUrl || config.url, 'http://fake', querystringWithArraySupport); const params = Object.assign({}, parts.query, config.params); const event = { diff --git a/yarn.lock b/yarn.lock index 626e9b8..4a1da57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5754,10 +5754,10 @@ url-parse-lax@^3.0.0: dependencies: prepend-http "^2.0.0" -url-parse@^1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278" - integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg== +url-parse@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.0.tgz#90aba6c902aeb2d80eac17b91131c27665d5d828" + integrity sha512-9iT6N4s93SMfzunOyDPe4vo4nLcSu1yq0IQK1gURmjm8tQNlM6loiuCRrKG1hHGXfB2EWd6H4cGi7tGdaygMFw== dependencies: querystringify "^2.1.1" requires-port "^1.0.0"