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 17
17
import { Loader , LoaderOptions } from "." ;
18
18
19
19
test . each ( [
20
+ [ { } , "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback" ] ,
20
21
[
21
22
{ apiKey : "foo" } ,
22
23
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&key=foo" ,
@@ -114,9 +115,3 @@ test("loader should wait if already loading", () => {
114
115
115
116
loader . load ( ) ;
116
117
} ) ;
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 {
192
192
region,
193
193
version,
194
194
} : LoaderOptions ) {
195
- if ( typeof apiKey !== "string" || ! apiKey ) {
196
- throw "Invalid apiKey " + apiKey ;
197
- }
198
-
199
195
this . version = version ;
200
196
this . apiKey = apiKey ;
201
197
this . libraries = libraries ;
@@ -211,7 +207,10 @@ export class Loader {
211
207
let url = this . URL ;
212
208
213
209
url += `?callback=${ this . CALLBACK } ` ;
214
- url += `&key=${ this . apiKey } ` ;
210
+
211
+ if ( this . apiKey ) {
212
+ url += `&key=${ this . apiKey } ` ;
213
+ }
215
214
216
215
if ( this . libraries . length > 0 ) {
217
216
url += `&libraries=${ this . libraries . join ( "," ) } ` ;
You can’t perform that action at this time.
0 commit comments