-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from AppsFlyerSDK/DELIVERY-62168/semverBugFix
Delivery 62168/semver bug fix
- Loading branch information
Showing
7 changed files
with
3,946 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {isVersionGreaterThanOrEqualTo} from "../../src/platforms/utils/utils.js" | ||
|
||
const MINIMUM_OS_VERSION_SUPPORTED = "4.0.0" | ||
let falseDataSet = ["1.0.0", "1.0", "2.0", "3.99", "3.9", "0", "0.0", null, undefined, "", 0, 2] | ||
let trueDataSet = ["4", "4.0.0", "4.1", "4.0.1", "5", "5.0", "5.0.0", 4, 4.1, 5, 5.5, 44] | ||
|
||
|
||
it.each(falseDataSet)("false response for isVersionGreaterThanOrEqualTo", async (version) => { | ||
console.log(version) | ||
expect(isVersionGreaterThanOrEqualTo(version, MINIMUM_OS_VERSION_SUPPORTED)).toEqual(false); | ||
}) | ||
|
||
it.each(trueDataSet)("true response for isVersionGreaterThanOrEqualTo", async (version) => { | ||
console.log(version) | ||
expect(isVersionGreaterThanOrEqualTo(version, MINIMUM_OS_VERSION_SUPPORTED)).toEqual(true); | ||
}) | ||
|
||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const DEFAULT_DEVICE_ID = "00000000-0000-0000-0000-000000000000"; | ||
|
||
export const DEFAULT_APP_VERSION = '0.0.0'; | ||
export const DEFAULT_APP_VERSION = '0.0.0'; | ||
export const MINIMUM_OS_VERSION_SUPPORTED= '4.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export const isVersionGreaterThanOrEqualTo = (versionA, versionB) => { | ||
const isValidVersion = (version) => { | ||
return version !== null && version !== undefined && version !== ""; | ||
}; | ||
|
||
if (!isValidVersion(versionA)) { | ||
return false; | ||
} | ||
|
||
const normalizeVersion = (v) => v.split('.').map(part => parseInt(part, 10)); // Normalize version string | ||
|
||
const compareVersions = (partsA, partsB) => { | ||
const maxLength = Math.max(partsA.length, partsB.length); | ||
|
||
for (let i = 0; i < maxLength; i++) { | ||
const partA = partsA[i] || 0; // Use 0 if no more parts in version | ||
const partB = partsB[i] || 0; // Use 0 if no more parts in version | ||
|
||
if (partA > partB) { | ||
return true; | ||
} else if (partA < partB) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; // Versions are equal | ||
}; | ||
|
||
const partsA = normalizeVersion(typeof versionA === 'number' ? versionA.toString() : versionA); | ||
const partsB = normalizeVersion(versionB); | ||
|
||
return compareVersions(partsA, partsB); | ||
}; |
Oops, something went wrong.