From c99265ef07d486e633d7642a1e68061a756b1e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojtech=20Ma=C5=A1ek?= Date: Fri, 10 Aug 2018 17:18:43 +0200 Subject: [PATCH] fix(api-client): empty string as valid domain URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vojtech MaĊĦek --- templates/ngx-module-export.mustache | 2 +- templates/ngx-service.mustache | 8 ++++---- tests/custom/api/api-client.service.ts | 8 ++++---- tests/custom/api/index.ts | 2 +- tests/esquare/api/api-client.service.ts | 8 ++++---- tests/esquare/api/index.ts | 2 +- .../api/dummy-selector/dummy-selector.service.ts | 8 ++++---- tests/filtered-api/api/project/project.service.ts | 8 ++++---- tests/gcloud-firestore/api/api-client.service.ts | 8 ++++---- tests/gcloud-firestore/api/index.ts | 2 +- tests/github/api/api-client.service.ts | 8 ++++---- tests/github/api/index.ts | 2 +- tests/with-all-tags/api/dashboard/dashboard.service.ts | 8 ++++---- tests/with-all-tags/api/dashboard/index.ts | 2 +- .../api/dummy-selector/dummy-selector.service.ts | 8 ++++---- tests/with-all-tags/api/dummy-selector/index.ts | 2 +- tests/with-all-tags/api/project/index.ts | 2 +- tests/with-all-tags/api/project/project.service.ts | 8 ++++---- 18 files changed, 48 insertions(+), 48 deletions(-) diff --git a/templates/ngx-module-export.mustache b/templates/ngx-module-export.mustache index 7ea27ece..76711303 100644 --- a/templates/ngx-module-export.mustache +++ b/templates/ngx-module-export.mustache @@ -46,7 +46,7 @@ export class {{&serviceName}}Module { return { ngModule: {{&serviceName}}Module, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), {{&serviceName}} ] diff --git a/templates/ngx-service.mustache b/templates/ngx-service.mustache index 1e6d095e..8f425413 100644 --- a/templates/ngx-service.mustache +++ b/templates/ngx-service.mustache @@ -25,13 +25,13 @@ export class {{&serviceName}} implements {{&interfaceName}} { readonly options: APIHttpOptions; - private readonly domain: string = `{{&domain}}`; + readonly domain: string = `{{&domain}}`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/custom/api/api-client.service.ts b/tests/custom/api/api-client.service.ts index cb97073e..16ea54da 100644 --- a/tests/custom/api/api-client.service.ts +++ b/tests/custom/api/api-client.service.ts @@ -23,13 +23,13 @@ export class APIClient implements APIClientInterface { readonly options: APIHttpOptions; - private readonly domain: string = `//${window.location.hostname}${window.location.port ? ':'+window.location.port : ''}`; + readonly domain: string = `//${window.location.hostname}${window.location.port ? ':'+window.location.port : ''}`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/custom/api/index.ts b/tests/custom/api/index.ts index 7144d7fb..aaf11d2e 100644 --- a/tests/custom/api/index.ts +++ b/tests/custom/api/index.ts @@ -44,7 +44,7 @@ export class APIClientModule { return { ngModule: APIClientModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), APIClient ] diff --git a/tests/esquare/api/api-client.service.ts b/tests/esquare/api/api-client.service.ts index f8e3d7c5..aa222a69 100644 --- a/tests/esquare/api/api-client.service.ts +++ b/tests/esquare/api/api-client.service.ts @@ -23,13 +23,13 @@ export class APIClient implements APIClientInterface { readonly options: APIHttpOptions; - private readonly domain: string = `https://virtserver.swaggerhub.com/Esquare/EsquareAPI/1.0.0`; + readonly domain: string = `https://virtserver.swaggerhub.com/Esquare/EsquareAPI/1.0.0`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/esquare/api/index.ts b/tests/esquare/api/index.ts index 7144d7fb..aaf11d2e 100644 --- a/tests/esquare/api/index.ts +++ b/tests/esquare/api/index.ts @@ -44,7 +44,7 @@ export class APIClientModule { return { ngModule: APIClientModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), APIClient ] diff --git a/tests/filtered-api/api/dummy-selector/dummy-selector.service.ts b/tests/filtered-api/api/dummy-selector/dummy-selector.service.ts index ea719845..0b81e55c 100644 --- a/tests/filtered-api/api/dummy-selector/dummy-selector.service.ts +++ b/tests/filtered-api/api/dummy-selector/dummy-selector.service.ts @@ -23,13 +23,13 @@ export class DummySelectorService implements DummySelectorInterface { readonly options: APIHttpOptions; - private readonly domain: string = `http://localhost:49801`; + readonly domain: string = `http://localhost:49801`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/filtered-api/api/project/project.service.ts b/tests/filtered-api/api/project/project.service.ts index c134f0a8..79a34680 100644 --- a/tests/filtered-api/api/project/project.service.ts +++ b/tests/filtered-api/api/project/project.service.ts @@ -23,13 +23,13 @@ export class ProjectService implements ProjectInterface { readonly options: APIHttpOptions; - private readonly domain: string = `http://localhost:49801`; + readonly domain: string = `http://localhost:49801`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/gcloud-firestore/api/api-client.service.ts b/tests/gcloud-firestore/api/api-client.service.ts index 74a16247..33f48a9d 100644 --- a/tests/gcloud-firestore/api/api-client.service.ts +++ b/tests/gcloud-firestore/api/api-client.service.ts @@ -23,13 +23,13 @@ export class APIClient implements APIClientInterface { readonly options: APIHttpOptions; - private readonly domain: string = `https://firestore.googleapis.com/v1beta1`; + readonly domain: string = `https://firestore.googleapis.com/v1beta1`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/gcloud-firestore/api/index.ts b/tests/gcloud-firestore/api/index.ts index 7144d7fb..aaf11d2e 100644 --- a/tests/gcloud-firestore/api/index.ts +++ b/tests/gcloud-firestore/api/index.ts @@ -44,7 +44,7 @@ export class APIClientModule { return { ngModule: APIClientModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), APIClient ] diff --git a/tests/github/api/api-client.service.ts b/tests/github/api/api-client.service.ts index 5303f582..fa2bdd2e 100644 --- a/tests/github/api/api-client.service.ts +++ b/tests/github/api/api-client.service.ts @@ -23,13 +23,13 @@ export class APIClient implements APIClientInterface { readonly options: APIHttpOptions; - private readonly domain: string = `https://api.github.com`; + readonly domain: string = `https://api.github.com`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/github/api/index.ts b/tests/github/api/index.ts index 7144d7fb..aaf11d2e 100644 --- a/tests/github/api/index.ts +++ b/tests/github/api/index.ts @@ -44,7 +44,7 @@ export class APIClientModule { return { ngModule: APIClientModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), APIClient ] diff --git a/tests/with-all-tags/api/dashboard/dashboard.service.ts b/tests/with-all-tags/api/dashboard/dashboard.service.ts index 2aa3cecc..bca5267f 100644 --- a/tests/with-all-tags/api/dashboard/dashboard.service.ts +++ b/tests/with-all-tags/api/dashboard/dashboard.service.ts @@ -23,13 +23,13 @@ export class DashboardService implements DashboardInterface { readonly options: APIHttpOptions; - private readonly domain: string = `http://localhost:49801`; + readonly domain: string = `http://localhost:49801`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/with-all-tags/api/dashboard/index.ts b/tests/with-all-tags/api/dashboard/index.ts index 3dbaf507..b0419819 100644 --- a/tests/with-all-tags/api/dashboard/index.ts +++ b/tests/with-all-tags/api/dashboard/index.ts @@ -44,7 +44,7 @@ export class DashboardServiceModule { return { ngModule: DashboardServiceModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), DashboardService ] diff --git a/tests/with-all-tags/api/dummy-selector/dummy-selector.service.ts b/tests/with-all-tags/api/dummy-selector/dummy-selector.service.ts index ea719845..0b81e55c 100644 --- a/tests/with-all-tags/api/dummy-selector/dummy-selector.service.ts +++ b/tests/with-all-tags/api/dummy-selector/dummy-selector.service.ts @@ -23,13 +23,13 @@ export class DummySelectorService implements DummySelectorInterface { readonly options: APIHttpOptions; - private readonly domain: string = `http://localhost:49801`; + readonly domain: string = `http://localhost:49801`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; } diff --git a/tests/with-all-tags/api/dummy-selector/index.ts b/tests/with-all-tags/api/dummy-selector/index.ts index f0b77b36..2903f26e 100644 --- a/tests/with-all-tags/api/dummy-selector/index.ts +++ b/tests/with-all-tags/api/dummy-selector/index.ts @@ -44,7 +44,7 @@ export class DummySelectorServiceModule { return { ngModule: DummySelectorServiceModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), DummySelectorService ] diff --git a/tests/with-all-tags/api/project/index.ts b/tests/with-all-tags/api/project/index.ts index 5762de0c..38d38765 100644 --- a/tests/with-all-tags/api/project/index.ts +++ b/tests/with-all-tags/api/project/index.ts @@ -44,7 +44,7 @@ export class ProjectServiceModule { return { ngModule: ProjectServiceModule, providers: [ - ...(config.domain ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), + ...(config.domain != null ? [{provide: USE_DOMAIN, useValue: config.domain}] : []), ...(config.httpOptions ? [{provide: USE_HTTP_OPTIONS, useValue: config.httpOptions}] : []), ProjectService ] diff --git a/tests/with-all-tags/api/project/project.service.ts b/tests/with-all-tags/api/project/project.service.ts index c134f0a8..79a34680 100644 --- a/tests/with-all-tags/api/project/project.service.ts +++ b/tests/with-all-tags/api/project/project.service.ts @@ -23,13 +23,13 @@ export class ProjectService implements ProjectInterface { readonly options: APIHttpOptions; - private readonly domain: string = `http://localhost:49801`; + readonly domain: string = `http://localhost:49801`; constructor(private readonly http: HttpClient, - @Optional() @Inject(USE_DOMAIN) domain: string, - @Optional() @Inject(USE_HTTP_OPTIONS) options: DefaultHttpOptions) { + @Optional() @Inject(USE_DOMAIN) domain?: string, + @Optional() @Inject(USE_HTTP_OPTIONS) options?: DefaultHttpOptions) { - if (domain) { + if (domain != null) { this.domain = domain; }