mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 22:48:06 +00:00
b106668a95
- Convert `param: T | undefined = undefined` to optional `param?: T`. - Drop dead `= false` defaults on the required cache-provider options. - Make `GraphqlPaginatedContent.nodes/edges` optional so the `= []` fallbacks (load-bearing for partial GraphQL connections) are valid. - Type the unchecked `default_branch` response field as optional so the `'HEAD'` fallback is retained. - Drop `tag = undefined` from the Forgejo/Gitea/GitLab preset configs. Part of #43845 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { parseJson } from '../common.ts';
|
|
import { regEx } from '../regex.ts';
|
|
import { isHttpUrl } from '../url.ts';
|
|
import { HttpBase, type InternalHttpOptions } from './http.ts';
|
|
import type { HttpOptions } from './types.ts';
|
|
|
|
let baseUrl: string;
|
|
export function setBaseUrl(url: string): void {
|
|
baseUrl = url;
|
|
}
|
|
|
|
/**
|
|
* Access Gerrit REST-API and strip-of the "magic prefix" from responses.
|
|
* @see https://gerrit-review.googlesource.com/Documentation/rest-api.html
|
|
*/
|
|
export class GerritHttp extends HttpBase {
|
|
private static magicPrefix = regEx(/^\)]}'\n/g);
|
|
|
|
protected override get baseUrl(): string | undefined {
|
|
return baseUrl;
|
|
}
|
|
|
|
constructor(options?: HttpOptions) {
|
|
super('gerrit', options);
|
|
}
|
|
|
|
override resolveUrl(requestUrl: string | URL, options?: HttpOptions): URL {
|
|
// ensure trailing slash for gerrit
|
|
return super.resolveUrl(
|
|
isHttpUrl(requestUrl) ? requestUrl : `${baseUrl}${requestUrl}`,
|
|
options,
|
|
);
|
|
}
|
|
|
|
protected override processOptions(
|
|
url: URL,
|
|
options: InternalHttpOptions,
|
|
): void {
|
|
options.parseJson = (text: string) =>
|
|
parseJson(text.replace(GerritHttp.magicPrefix, ''), url.pathname);
|
|
}
|
|
}
|