chore(http): assert that url is present when creating new Request
Closes #4650
This commit is contained in:
parent
1dc8a0a95d
commit
ebd15a7855
|
@ -23,10 +23,10 @@ export abstract class Connection {
|
|||
}
|
||||
|
||||
/**
|
||||
* Interface for options to construct a Request, based on
|
||||
* Interface for options to construct a RequestOptions, based on
|
||||
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
|
||||
*/
|
||||
export type RequestOptionsArgs = {
|
||||
export interface RequestOptionsArgs {
|
||||
url?: string;
|
||||
method?: string | RequestMethods;
|
||||
search?: string | URLSearchParams;
|
||||
|
@ -35,6 +35,11 @@ export type RequestOptionsArgs = {
|
|||
body?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required structure when constructing new Request();
|
||||
*/
|
||||
export interface RequestArgs extends RequestOptionsArgs { url: string; }
|
||||
|
||||
/**
|
||||
* Interface for options to construct a Response, based on
|
||||
* [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {RequestMethods} from './enums';
|
||||
import {RequestOptions} from './base_request_options';
|
||||
import {RequestArgs} from './interfaces';
|
||||
import {Headers} from './headers';
|
||||
import {normalizeMethodName} from './http_utils';
|
||||
import {
|
||||
|
@ -61,7 +61,7 @@ export class Request {
|
|||
url: string;
|
||||
// TODO: support URLSearchParams | FormData | Blob | ArrayBuffer
|
||||
private _body: string;
|
||||
constructor(requestOptions: RequestOptions) {
|
||||
constructor(requestOptions: RequestArgs) {
|
||||
// TODO: assert that url is present
|
||||
let url = requestOptions.url;
|
||||
this.url = requestOptions.url;
|
||||
|
|
Loading…
Reference in New Issue