UNPKG

cumulocity-cypress

Version:
46 lines (45 loc) 2.12 kB
import { C8yBaseUrl, C8yTenant } from "./types"; import { C8yPactRecord } from "./c8ypact/c8ypact"; export declare function isURL(obj: any): obj is URL; export declare function relativeURL(url: URL | string): string | undefined; export declare function urlForBaseUrl(baseUrl: string, relativeOrAbsoluteUrl?: string): string | undefined; export declare function removeBaseUrlFromString(url: string, baseUrl?: C8yBaseUrl): string; export declare function removeBaseUrlFromRequestUrl(record: C8yPactRecord, baseUrl?: C8yBaseUrl): void; export declare function normalizeUrl(url: string): string; export declare function tenantUrl(baseUrl?: C8yBaseUrl, tenant?: C8yTenant): string | undefined; export declare function updateURLs(value: string, from: { baseUrl: C8yBaseUrl; tenant?: C8yTenant; }, to: { baseUrl: C8yBaseUrl; tenant?: C8yTenant; }): string; /** * Checks if the given URL is an absolute URL. * @param url The URL to check. * @returns True if the URL is an absolute URL, false otherwise. */ export declare function isAbsoluteURL(url: string): boolean; /** * Validates the base URL and throws an error if the base URL is not an absolute URL. This * is required as commands expect an absolute URL as baseUrl. Will not fail for undefined values. * `Cypress.config().baseUrl` is validated by Cypress itself and throw an error. * * @param baseUrl The url to validate. */ export declare function validateBaseUrl(baseUrl?: C8yBaseUrl): void; /** * Normalizes a URL to ensure it has a protocol and proper trailing slash. * If no protocol is present, HTTPS is added by default. * If the URL has no path component, a trailing slash is appended. * * @param url - The URL string to normalize * @returns The normalized URL with HTTPS protocol and trailing slash if appropriate, or undefined for invalid input */ export declare function normalizeBaseUrl(url: string | undefined): string | undefined; /** * Converts the given URL to a string. * @param url The URL or RequestInfo to convert. * @returns The URL as a string. */ export declare function toUrlString(url: RequestInfo | URL): string;