Skip to content

Commit

Permalink
fix(api-client): empty string as valid domain URL
Browse files Browse the repository at this point in the history
Signed-off-by: Vojtech Mašek <[email protected]>
  • Loading branch information
vmasek committed Aug 10, 2018
1 parent f847e52 commit c99265e
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion templates/ngx-module-export.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
]
Expand Down
8 changes: 4 additions & 4 deletions templates/ngx-service.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/custom/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/custom/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
8 changes: 4 additions & 4 deletions tests/esquare/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/esquare/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/filtered-api/api/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/gcloud-firestore/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/gcloud-firestore/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
8 changes: 4 additions & 4 deletions tests/github/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/github/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
8 changes: 4 additions & 4 deletions tests/with-all-tags/api/dashboard/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/with-all-tags/api/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/with-all-tags/api/dummy-selector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
2 changes: 1 addition & 1 deletion tests/with-all-tags/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
8 changes: 4 additions & 4 deletions tests/with-all-tags/api/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c99265e

Please sign in to comment.