Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9149f1c

Browse files
committed
Fix parsing semver of urls
1 parent a4c099e commit 9149f1c

File tree

1 file changed

+10
-1
lines changed
  • packages/app/src/sandbox/eval/presets/create-react-app

1 file changed

+10
-1
lines changed

packages/app/src/sandbox/eval/presets/create-react-app/utils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import semver from 'semver';
22
import { getAbsoluteDependencies } from '@codesandbox/common/lib/utils/dependencies';
33
import Manager from 'sandbox/eval/manager';
44

5+
function isMinimalSemverVersion(version: string, minimalVersion: string) {
6+
try {
7+
return semver.gte(version, minimalVersion);
8+
} catch (e) {
9+
// Semver couldn't be parsed, we assume that we're on the bleeding edge now, so true.
10+
return true;
11+
}
12+
}
13+
514
export async function isMinimalReactVersion(
615
version: string,
716
minimalVersion: string
@@ -13,7 +22,7 @@ export async function isMinimalReactVersion(
1322

1423
return (
1524
absoluteDependencies['react-dom'].startsWith('0.0.0') ||
16-
semver.gte(absoluteDependencies['react-dom'], minimalVersion)
25+
isMinimalSemverVersion(absoluteDependencies['react-dom'], minimalVersion)
1726
);
1827
}
1928

0 commit comments

Comments
 (0)