@paypal/sdk-client
Advanced tools
Comparing version
{ | ||
"name": "@paypal/sdk-client", | ||
"version": "4.0.164", | ||
"version": "4.0.165", | ||
"description": "Shared config between PayPal/Braintree.", | ||
@@ -26,3 +26,4 @@ "main": "index.js", | ||
"prepublishOnly": "npm run babel", | ||
"postpublish": "rm -rf ./server && git checkout ./server" | ||
"postpublish": "rm -rf ./server && git checkout ./server", | ||
"validate-codecov": "curl --data-binary @.github/codecov.yml https://codecov.io/validate" | ||
}, | ||
@@ -68,5 +69,5 @@ "files": [ | ||
"grumbler-scripts": "^5.0.0", | ||
"mocha": "4.1.0", | ||
"mocha": "9.2.1", | ||
"sync-browser-mocks": "2.0.8" | ||
} | ||
} |
@@ -111,2 +111,13 @@ "use strict"; | ||
function validateHostAndPath(hostname, pathname) { | ||
if (!pathname || !hostname) { | ||
throw new Error(`Expected host and pathname to be passed for sdk url`); | ||
} | ||
return { | ||
hostname, | ||
pathname | ||
}; | ||
} | ||
function validateSDKUrl(sdkUrl) { | ||
@@ -116,4 +127,4 @@ const { | ||
host, | ||
hostname, | ||
pathname, | ||
hostname: sourceHostname, | ||
pathname: sourcePathname, | ||
query, | ||
@@ -123,10 +134,7 @@ hash | ||
if (!hostname) { | ||
throw new Error(`Expected host to be passed for sdk url`); | ||
} | ||
const { | ||
hostname, | ||
pathname | ||
} = validateHostAndPath(sourceHostname, sourcePathname); | ||
if (!pathname) { | ||
throw new Error(`Expected pathname for sdk url`); | ||
} | ||
if (!sdkUrl.startsWith(_constants.PROTOCOL.HTTP) && !sdkUrl.startsWith(_constants.PROTOCOL.HTTPS)) { | ||
@@ -179,14 +187,11 @@ throw new Error(`Expected protocol for sdk url to be ${_constants.PROTOCOL.HTTP} or ${_constants.PROTOCOL.HTTPS} for host: ${hostname} - got ${protocol || 'undefined'}`); | ||
const { | ||
hostname: sourceHostname, | ||
pathname: sourcePathname | ||
} = _url.default.parse(sdkUrl, true); | ||
const { | ||
hostname, | ||
pathname | ||
} = _url.default.parse(sdkUrl, true); | ||
} = validateHostAndPath(sourceHostname, sourcePathname); | ||
if (!hostname) { | ||
throw new Error(`Expected host to be passed for sdk url`); | ||
} | ||
if (!pathname) { | ||
throw new Error(`Expected pathname for sdk url`); | ||
} | ||
if (isLegacySDKUrl(hostname, pathname)) { | ||
@@ -193,0 +198,0 @@ attrs[_constants.DATA_ATTRIBUTES.PAYPAL_CHECKOUT] = true; |
@@ -113,12 +113,12 @@ /* @flow */ | ||
function validateSDKUrl(sdkUrl : string) { | ||
const { protocol, host, hostname, pathname, query, hash } = urlLib.parse(sdkUrl, true); | ||
if (!hostname) { | ||
throw new Error(`Expected host to be passed for sdk url`); | ||
function validateHostAndPath(hostname : string | null, pathname : string | null) : { hostname : string, pathname : string } { | ||
if (!pathname || !hostname) { | ||
throw new Error(`Expected host and pathname to be passed for sdk url`); | ||
} | ||
return { hostname, pathname }; | ||
} | ||
if (!pathname) { | ||
throw new Error(`Expected pathname for sdk url`); | ||
} | ||
function validateSDKUrl(sdkUrl : string) { | ||
const { protocol, host, hostname: sourceHostname, pathname : sourcePathname, query, hash } = urlLib.parse(sdkUrl, true); | ||
const { hostname, pathname } = validateHostAndPath(sourceHostname, sourcePathname); | ||
@@ -178,12 +178,5 @@ if (!sdkUrl.startsWith(PROTOCOL.HTTP) && !sdkUrl.startsWith(PROTOCOL.HTTPS)) { | ||
if (sdkUrl) { | ||
const { hostname, pathname } = urlLib.parse(sdkUrl, true); | ||
const { hostname: sourceHostname, pathname: sourcePathname } = urlLib.parse(sdkUrl, true); | ||
const { hostname, pathname } = validateHostAndPath(sourceHostname, sourcePathname); | ||
if (!hostname) { | ||
throw new Error(`Expected host to be passed for sdk url`); | ||
} | ||
if (!pathname) { | ||
throw new Error(`Expected pathname for sdk url`); | ||
} | ||
if (isLegacySDKUrl(hostname, pathname)) { | ||
@@ -190,0 +183,0 @@ attrs[DATA_ATTRIBUTES.PAYPAL_CHECKOUT] = true; |
81748
0.46%1613
0.06%