@@ -81,8 +81,8 @@ export class ChromeXml extends XmlConfigSource {
81
81
latest = item ;
82
82
latestVersion = item . split ( '/' ) [ 0 ] ;
83
83
} else if (
84
- iterVersion . startsWith ( this . maxVersion ) &&
85
- semver . gt ( iterVersion , chromedriverVersion ) ) {
84
+ iterVersion . startsWith ( this . maxVersion ) &&
85
+ semver . gt ( iterVersion , chromedriverVersion ) ) {
86
86
// After the first time, make sure the semantic version is greater.
87
87
chromedriverVersion = iterVersion ;
88
88
latest = item ;
@@ -107,34 +107,78 @@ export class ChromeXml extends XmlConfigSource {
107
107
*/
108
108
private getSpecificChromeDriverVersion ( inputVersion : string ) : Promise < BinaryUrl > {
109
109
return this . getVersionList ( ) . then ( list => {
110
- const specificVersion = getValidSemver ( inputVersion ) ;
111
- if ( specificVersion === '' ) {
112
- throw new Error ( `version ${ inputVersion } ChromeDriver does not exist` )
113
- }
110
+
111
+ const isLong = inputVersion . split ( '.' ) . length === 4 ;
114
112
let itemFound = '' ;
115
- for ( let item of list ) {
116
- // Get a semantic version.
117
- let version = item . split ( '/' ) [ 0 ] ;
118
- if ( semver . valid ( version ) == null ) {
119
- const lookUpVersion = getValidSemver ( version ) ;
120
-
121
- if ( semver . valid ( lookUpVersion ) ) {
122
- // Check to see if the specified version matches.
123
- if ( lookUpVersion === specificVersion ) {
124
- // When item found is null, check the os arch
125
- // 64-bit version works OR not 64-bit version and the path does not have '64'
126
- if ( itemFound == '' ) {
127
- if ( this . osarch === 'x64' ||
113
+
114
+ if ( ! isLong ) {
115
+ const specificVersion = getValidSemver ( inputVersion ) ;
116
+ if ( specificVersion === '' ) {
117
+ throw new Error ( `version ${ inputVersion } ChromeDriver does not exist` )
118
+ }
119
+ for ( let item of list ) {
120
+ // Get a semantic version.
121
+ let version = item . split ( '/' ) [ 0 ] ;
122
+ if ( semver . valid ( version ) == null ) {
123
+ const lookUpVersion = getValidSemver ( version ) ;
124
+
125
+ if ( semver . valid ( lookUpVersion ) ) {
126
+ // Check to see if the specified version matches.
127
+ if ( lookUpVersion === specificVersion ) {
128
+ // When item found is null, check the os arch
129
+ // 64-bit version works OR not 64-bit version and the path does not have '64'
130
+ if ( itemFound == '' ) {
131
+ if ( this . osarch === 'x64' ||
128
132
( this . osarch !== 'x64' && ! item . includes ( this . getOsTypeName ( ) + '64' ) ) ) {
129
- itemFound = item ;
130
- }
133
+ itemFound = item ;
134
+ }
131
135
136
+ }
137
+ // If the semantic version is the same, check os arch.
138
+ // For 64-bit systems, prefer the 64-bit version.
139
+ else if ( this . osarch === 'x64' ) {
140
+ if ( item . includes ( this . getOsTypeName ( ) + '64' ) ) {
141
+ itemFound = item ;
142
+ }
143
+ }
132
144
}
133
- // If the semantic version is the same, check os arch.
134
- // For 64-bit systems, prefer the 64-bit version.
135
- else if ( this . osarch === 'x64' ) {
136
- if ( item . includes ( this . getOsTypeName ( ) + '64' ) ) {
137
- itemFound = item ;
145
+ }
146
+ }
147
+ }
148
+ } else {
149
+ // Splitting to two semver objects because of clunky chromedriver versioning
150
+ // Supports e.g. 76.0.3809.68 while not ignoring the last patch number
151
+ const inputVersionPart1 = inputVersion . split ( '.' ) . slice ( 0 , 3 ) . join ( '.' ) ;
152
+ const inputVersionPart2 = inputVersion . split ( '.' ) . slice ( 1 , 4 ) . join ( '.' ) ;
153
+
154
+ const specificVersion1 = getValidSemver ( inputVersionPart1 ) ;
155
+ const specificVersion2 = getValidSemver ( inputVersionPart2 ) ;
156
+ if ( specificVersion1 === '' || specificVersion2 === '' ) {
157
+ throw new Error ( `version ${ inputVersion } ChromeDriver does not exist` ) ;
158
+ }
159
+
160
+ for ( let item of list ) {
161
+ // Get a semantic version.
162
+ let version = item . split ( '/' ) [ 0 ] ;
163
+ if ( semver . valid ( version ) == null ) {
164
+ const versionPt1 = version . split ( '.' ) . slice ( 0 , 3 ) . join ( '.' ) ;
165
+ const versionPt2 = version . split ( '.' ) . slice ( 1 , 4 ) . join ( '.' ) ;
166
+ const lookUpVersion1 = getValidSemver ( versionPt1 ) ;
167
+ const lookUpVersion2 = getValidSemver ( versionPt2 ) ;
168
+ if ( semver . valid ( lookUpVersion1 ) && semver . valid ( lookUpVersion2 ) ) {
169
+ // Check to see if the specified version matches.
170
+ if ( lookUpVersion1 === specificVersion1 && lookUpVersion2 === specificVersion2 ) {
171
+ // When item found is null, check the os arch
172
+ // 64-bit version works OR not 64-bit version and the path does not have '64'
173
+ if ( itemFound == '' ) {
174
+ if ( this . osarch === 'x64' ||
175
+ ( this . osarch !== 'x64' && ! item . includes ( this . getOsTypeName ( ) + '64' ) ) ) {
176
+ itemFound = item ;
177
+ }
178
+ } else if ( this . osarch === 'x64' ) {
179
+ if ( item . includes ( this . getOsTypeName ( ) + '64' ) ) {
180
+ itemFound = item ;
181
+ }
138
182
}
139
183
}
140
184
}
@@ -176,7 +220,7 @@ export function getValidSemver(version: string): string {
176
220
}
177
221
// This supports downloading 74.0.3729.6
178
222
try {
179
- const newRegex = / ( \d + .\d + .\d + ) . \d + / g;
223
+ const newRegex = / ( \d + .\d + .\d + ) / g;
180
224
const exec = newRegex . exec ( version ) ;
181
225
if ( exec ) {
182
226
lookUpVersion = exec [ 1 ] ;
0 commit comments