Skip to content

Commit

Permalink
feat: support relative baseUrls (#950)
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
  • Loading branch information
toddbaert committed Jun 18, 2024
1 parent 4aec2ef commit ceb42cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 0 additions & 7 deletions libs/providers/ofrep-web/src/lib/ofrep-web-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ export class OFREPWebProvider implements Provider {
private _pollingIntervalId?: number;

constructor(options: OFREPWebProviderOptions, logger?: Logger) {
try {
// Cannot use URL.canParse as it is only available from Node 19.x
new URL(options.baseUrl);
} catch {
throw new Error(`The given OFREP URL "${options.baseUrl}" is not a valid URL.`);
}

this._options = options;
this._logger = logger;
this._etag = null;
Expand Down
17 changes: 17 additions & 0 deletions libs/shared/ofrep-core/src/lib/provider/ofrep-provider-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ export type HttpHeaderMap = Record<string, string>;
export type HttpHeaders = HttpHeaderList | HttpHeaderMap;

export type OFREPProviderBaseOptions = {
/**
* Base URL for OFREP requests. Relative paths are supported.
* For example, if your OFREP instance is available at
* "https://host.com/path/{ofrep-api}" , you should set this to
* "https://host.com/path" or "/path" (if your app and OFREP instance
* share the same origin).
*/
baseUrl: string;
/**
* Optional fetch implementation
*/
fetchImplementation?: FetchAPI;
/**
* Optional Headers supplier function.
* @returns HttpHeaders
*/
headersFactory?: () => HttpHeaders;
/**
* Optional static headers.
*/
headers?: HttpHeaders;
};

Expand Down

0 comments on commit ceb42cb

Please sign in to comment.