summarylogtreecommitdiffstats
path: root/browserslist.diff
blob: ff9fd5ffcf0436fcc543d2ab7082ad32a68c2ed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
diff --git a/index.js b/index.js
index 3a22ecc6..062eac27 100644
--- a/index.js
+++ b/index.js
@@ -33,6 +33,17 @@ function normalize (versions) {
   })
 }
 
+function normalizeElectron (version) {
+  var versionToUse = version
+  if (version.split('.').length === 3) {
+    versionToUse = version
+      .split('.')
+      .slice(0, -1)
+      .join('.')
+  }
+  return versionToUse
+}
+
 function nameMapper (name) {
   return function mapName (version) {
     return name + ' ' + version
@@ -768,10 +779,12 @@ var QUERIES = [
   {
     regexp: /^electron\s+([\d.]+)\s*-\s*([\d.]+)$/i,
     select: function (context, from, to) {
-      if (!e2c[from]) {
+      var fromToUse = normalizeElectron(from)
+      var toToUse = normalizeElectron(to)
+      if (!e2c[fromToUse]) {
         throw new BrowserslistError('Unknown version ' + from + ' of electron')
       }
-      if (!e2c[to]) {
+      if (!e2c[toToUse]) {
         throw new BrowserslistError('Unknown version ' + to + ' of electron')
       }
 
@@ -804,8 +817,9 @@ var QUERIES = [
   {
     regexp: /^electron\s*(>=?|<=?)\s*([\d.]+)$/i,
     select: function (context, sign, version) {
+      var versionToUse = normalizeElectron(version)
       return Object.keys(e2c)
-        .filter(generateFilter(sign, version))
+        .filter(generateFilter(sign, versionToUse))
         .map(function (i) {
           return 'chrome ' + e2c[i]
         })
@@ -856,7 +870,8 @@ var QUERIES = [
   {
     regexp: /^electron\s+([\d.]+)$/i,
     select: function (context, version) {
-      var chrome = e2c[version]
+      var versionToUse = normalizeElectron(version)
+      var chrome = e2c[versionToUse]
       if (!chrome) {
         throw new BrowserslistError(
           'Unknown version ' + version + ' of electron')