File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 1717import { Loader , LoaderOptions } from "." ;
1818
1919test . each ( [
20+ [ { } , "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback" ] ,
2021 [
2122 { apiKey : "foo" } ,
2223 "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&key=foo" ,
@@ -114,9 +115,3 @@ test("loader should wait if already loading", () => {
114115
115116 loader . load ( ) ;
116117} ) ;
117-
118- test ( "loader should throw exception if invalid key format" , ( ) => {
119- expect ( ( ) => new Loader ( { apiKey : "" } ) ) . toThrow ( ) ;
120- expect ( ( ) => new Loader ( { apiKey : { } as string } ) ) . toThrow ( ) ;
121- expect ( ( ) => new Loader ( { apiKey : ( 1 as unknown ) as string } ) ) . toThrow ( ) ;
122- } ) ;
Original file line number Diff line number Diff line change @@ -192,10 +192,6 @@ export class Loader {
192192 region,
193193 version,
194194 } : LoaderOptions ) {
195- if ( typeof apiKey !== "string" || ! apiKey ) {
196- throw "Invalid apiKey " + apiKey ;
197- }
198-
199195 this . version = version ;
200196 this . apiKey = apiKey ;
201197 this . libraries = libraries ;
@@ -211,7 +207,10 @@ export class Loader {
211207 let url = this . URL ;
212208
213209 url += `?callback=${ this . CALLBACK } ` ;
214- url += `&key=${ this . apiKey } ` ;
210+
211+ if ( this . apiKey ) {
212+ url += `&key=${ this . apiKey } ` ;
213+ }
215214
216215 if ( this . libraries . length > 0 ) {
217216 url += `&libraries=${ this . libraries . join ( "," ) } ` ;
You can’t perform that action at this time.
0 commit comments