From 4fcf313816b3cbd736ea510859257815763e7cd0 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Tue, 13 Aug 2019 12:36:05 +0800 Subject: [PATCH] Fixed subscribers app when missing location no-issue The previous version of url-utils's absoluteToRelative function had some implicit behaviour that was relied on here. Namely that when passed an empty string as the url AND the withoutSubdirectory option set to true, we would end up calling the `replace` method on `null` - this would throw an error and cause the subscribers app to enter the error handling - which was desired behaviour. This updates to explicitly check, and execute the error handling based on the missing location property. --- core/frontend/apps/subscribers/lib/router.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/frontend/apps/subscribers/lib/router.js b/core/frontend/apps/subscribers/lib/router.js index 6c971d6e16..bb126f7645 100644 --- a/core/frontend/apps/subscribers/lib/router.js +++ b/core/frontend/apps/subscribers/lib/router.js @@ -59,6 +59,9 @@ function santizeUrl(url) { } function handleSource(req, res, next) { + if (!req.body.location) { + return next(new Error('Missing location property')); + } req.body.subscribed_url = santizeUrl(req.body.location); req.body.subscribed_referrer = santizeUrl(req.body.referrer);