@@ -152,26 +152,22 @@ export class ChromiumExtensionRunner {
152152
153153 const chromeFlags = [ ...DEFAULT_CHROME_FLAGS ] ;
154154 let startingUrl ;
155- var specialStartingUrls = '' ;
155+ var specialStartingUrls = [ ] ;
156156 if ( this . params . startUrl ) {
157157 const startingUrls = Array . isArray ( this . params . startUrl ) ?
158158 this . params . startUrl : [ this . params . startUrl ] ;
159159
160- // Remove URLs starting with chrome:// from startingUrls and let bg.js open them instead
161- for ( let i = 0 ; i < startingUrls . length ; i ++ ) {
162- if ( startingUrls [ i ] . toLowerCase ( ) . startsWith ( 'chrome://' ) ) {
163- specialStartingUrls += startingUrls [ i ] + " "
164- startingUrls . splice ( i , 1 )
160+ // Extract URLs starting with chrome:// from startingUrls and let bg.js open them instead
161+ startingUrls . forEach ( ( element ) => {
162+ if ( element . toLowerCase ( ) . startsWith ( 'chrome://' ) ) {
163+ specialStartingUrls . push ( element ) ;
165164 }
166- }
167-
168- startingUrl = startingUrls . shift ( ) ;
169-
170- chromeFlags . push ( ...startingUrls ) ;
165+ } ) ;
171166 }
172167
173168 // Create the extension that will manage the addon reloads
174- this . reloadManagerExtension = await this . createReloadManagerExtension ( specialStartingUrls ) ;
169+ this . reloadManagerExtension =
170+ await this . createReloadManagerExtension ( specialStartingUrls ) ;
175171
176172 // Start chrome pointing it to a given profile dir
177173 const extensions = [ this . reloadManagerExtension ] . concat (
@@ -231,6 +227,16 @@ export class ChromiumExtensionRunner {
231227 chromeFlags . push ( `--profile-directory=${ profileDirName } ` ) ;
232228 }
233229
230+ if ( this . params . startUrl ) {
231+ const startingUrls = Array . isArray ( this . params . startUrl ) ?
232+ this . params . startUrl : [ this . params . startUrl ] ;
233+
234+ const strippedStartingUrls = startingUrls . filter (
235+ ( item ) => ! ( item . toLowerCase ( ) . startsWith ( 'chrome://' ) ) ) ;
236+
237+ startingUrl = strippedStartingUrls . shift ( ) ;
238+ chromeFlags . push ( ...strippedStartingUrls ) ;
239+ }
234240
235241 this . chromiumInstance = await this . chromiumLaunch ( {
236242 enableExtensions : true ,
@@ -291,7 +297,8 @@ export class ChromiumExtensionRunner {
291297 } ) ;
292298 }
293299
294- async createReloadManagerExtension ( specialStartingUrls : string ) : Promise < string > {
300+ async createReloadManagerExtension (
301+ specialStartingUrls : Array < string > ) : Promise < string > {
295302 const tmpDir = new TempDir ( ) ;
296303 await tmpDir . create ( ) ;
297304 this . registerCleanup ( ( ) => tmpDir . remove ( ) ) ;
@@ -345,16 +352,15 @@ export class ChromiumExtensionRunner {
345352 const ws = new window.WebSocket(
346353 "ws://${ wssInfo . address } :${ wssInfo . port } ");
347354
348-
349- if (${ specialStartingUrls . length } > 0)
350- {
351- const chromeTabList = "${ specialStartingUrls } ".trim().split(" ")
355+
356+ const chromeTabList = ${ JSON . stringify ( specialStartingUrls ) }
357+ if (chromeTabList.length > 0) {
352358 chrome.runtime.onInstalled.addListener(details => {
353359 if (details.reason === chrome.runtime.OnInstalledReason.INSTALL ) {
354360 chromeTabList.forEach(url => {
355361 chrome.tabs.create({ url });
356362 });
357- }
363+ }
358364 });
359365 }
360366
0 commit comments