[extensions-web/ui-cleanup] js: Fix getProperExtensionVersion in the case of '3.2.2.1'



commit 947c568b8383b51a7325ddc92e7700d7efdfa4b8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jan 23 12:30:44 2012 -0500

    js: Fix getProperExtensionVersion in the case of '3.2.2.1'

 sweettooth/static/js/extensionUtils.js  |    5 ++++-
 sweettooth/static/js/test/extensions.js |    6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/static/js/extensionUtils.js b/sweettooth/static/js/extensionUtils.js
index fc76368..fd2e1b8 100644
--- a/sweettooth/static/js/extensionUtils.js
+++ b/sweettooth/static/js/extensionUtils.js
@@ -42,10 +42,13 @@ define([], function() {
         if (!map)
             return null;
 
-        var versionA = map[current];
+        // Only care about the first three parts -- look up
+        // "3.2.2" when given "3.2.2.1"
 
         var parts = current.split('.');
 
+        var versionA = map[(parts[0] + '.' + parts[1] + '.' + parts[2])];
+
         // Unstable releases
         if (parseInt(parts[1]) % 2 != 0) {
             if (versionA !== undefined)
diff --git a/sweettooth/static/js/test/extensions.js b/sweettooth/static/js/test/extensions.js
index 590e476..c5835a0 100644
--- a/sweettooth/static/js/test/extensions.js
+++ b/sweettooth/static/js/test/extensions.js
@@ -10,6 +10,8 @@ require(['extensionUtils', 'jquery', 'test/qunit'], function(extensionUtils) {
 
         equal(versionCheck(["3.2"], "3.2.1"), true, "stable release checking");
         equal(versionCheck(["3.3"], "3.3.1"), false);
+
+        equal(versionCheck(["3.2.2"], "3.2.2.1"), true, "ignoring the fourth field");
     });
 
     var grabProperExtensionVersion = extensionUtils.grabProperExtensionVersion;
@@ -19,7 +21,8 @@ require(['extensionUtils', 'jquery', 'test/qunit'], function(extensionUtils) {
                     "3.2.1": { version: 3, pk: 3 },
                     "3.2": { version: 4, pk: 4 },
                     "3.3": { version: 5, pk: 5 },
-                    "3.3.1": { version: 6, pk: 6 } };
+                    "3.3.1": { version: 6, pk: 6 },
+                    "3.4.1": { version: 7, pk: 7 } };
 
         equal(grabProperExtensionVersion(map, "3.4.0"), null);
         equal(grabProperExtensionVersion(map, "3.0.0").version, 1);
@@ -28,6 +31,7 @@ require(['extensionUtils', 'jquery', 'test/qunit'], function(extensionUtils) {
         equal(grabProperExtensionVersion(map, "3.2.1").version, 4);
         equal(grabProperExtensionVersion(map, "3.3.0"), null, "stable release checking");
         equal(grabProperExtensionVersion(map, "3.3.1").version, 6);
+        equal(grabProperExtensionVersion(map, "3.4.1.1").version, 7);
     });
 
     function nhvEqual(versions, current, operation, stability, version) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]