Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep v4 patch versions at 132 or above #213

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check .",
"test": "npm run format:check && npm run lint && npm run flow && npm run test:unit",
"test:unit": "vitest run --coverage",
"test:watch": "vitest",
"webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack -- --progress",
"test:unit:watch": "vitest --coverage",
"test:unit": "vitest run --coverage",
"prepublishOnly": "npm run babel",
"postpublish": "rm -rf ./server && git checkout ./server",
"validate-codecov": "curl --data-binary @.github/codecov.yml https://codecov.io/validate",
Expand Down
21 changes: 18 additions & 3 deletions server/meta.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import urlLib from "url";

import {
ENV,
SDK_PATH,
SDK_QUERY_KEYS,
SDK_SETTINGS,
Expand Down Expand Up @@ -167,8 +166,8 @@ function isLocalUrl(host: string): boolean {
HOST.LOCALTUNNEL,
];

// eslint-disable-next-line no-process-env
return (
// eslint-disable-next-line no-process-env
process.env.NODE_ENV === "development" &&
localUrls.some((url) => host.includes(url))
);
Expand All @@ -177,7 +176,7 @@ function isLocalUrl(host: string): boolean {
function validateHostAndPath(
hostname: string | null,
pathname: string | null
): { hostname: string, pathname: string } {
): {| hostname: string, pathname: string |} {
if (!pathname || !hostname) {
throw new Error(`Expected host and pathname to be passed for sdk url`);
}
Expand Down Expand Up @@ -206,6 +205,7 @@ function validateSDKUrl(sdkUrl: string) {
);
}

// eslint-disable-next-line no-useless-escape
const hostnameMatchResults = hostname.match(/[a-z0-9\.\-]+/);

if (!hostnameMatchResults || hostnameMatchResults[0] !== hostname) {
Expand Down Expand Up @@ -360,6 +360,21 @@ export function unpackSDKMeta(sdkMeta?: string): SDKMeta {
version = '';
}

// if patch version is less than 132, we want to
// set the version to 132. If for some reason we can't
// parse out a patch version, set version as latest
// if neither cases are true, leave version alone because
// it can be more than a semver version number ("min" for example)
if (/4\\.0\\.\\d{1,3}/.test(version)) {
var patchString = version?.split('.')?.pop()

if (!patchString) {
version = 'latest'
wsbrunson marked this conversation as resolved.
Show resolved Hide resolved
} else if (parseInt(patchString, 10) < 132) {
version = '4.0.132'
}
}

var url = '${baseURL}checkout' + (version ? ('.' + version) : '') + '.js';
var attributes = '${DATA_ATTRIBUTES.PAYPAL_CHECKOUT} ${DATA_ATTRIBUTES.NO_BRIDGE}';

Expand Down
Loading
Loading