Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add http host legacy error property #9263

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/util/http/legacy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// istanbul ignore file
import { parseUrl } from '../url';
import { HttpError } from './types';

// TODO: remove when code is refactored
Expand Down Expand Up @@ -32,6 +33,13 @@ Object.defineProperty(HttpError.prototype, 'url', {
},
});

Object.defineProperty(HttpError.prototype, 'host', {
get: function url(this: HttpError) {
const { host } = parseUrl(this.response?.url) ?? {};
return host;
},
});

export type GotLegacyError<E = unknown, T = unknown> = HttpError & {
statusCode?: number;
body: {
Expand Down