From 6e053579cf5e66ca2b1e84aea5d80ba5cbbe60bb Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Wed, 13 Mar 2019 11:13:28 -0700 Subject: [PATCH] Null check for missing pathname This is causing a crash if someone whitelists just a protocol, ex `file://` See #539 --- bin/templates/scripts/cordova/lib/prepare.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/templates/scripts/cordova/lib/prepare.js b/bin/templates/scripts/cordova/lib/prepare.js index f81085f82..278af0a8b 100644 --- a/bin/templates/scripts/cordova/lib/prepare.js +++ b/bin/templates/scripts/cordova/lib/prepare.js @@ -1052,7 +1052,9 @@ function parseWhitelistUrlForATS (url, options) { var subdomain1 = '/*.'; // wildcard in hostname var subdomain2 = '*://*.'; // wildcard in hostname and protocol var subdomain3 = '*://'; // wildcard in protocol only - if (href.pathname.indexOf(subdomain1) === 0) { + if(!href.pathname) { + return null; + } else if (href.pathname.indexOf(subdomain1) === 0) { retObj.NSIncludesSubdomains = true; retObj.Hostname = href.pathname.substring(subdomain1.length); } else if (href.pathname.indexOf(subdomain2) === 0) {