UNPKG

bc-node-sdk

Version:

BetterCommerce's NodeJS SDK encapsulates the base framework for all the Next.js applications.

44 lines (43 loc) 2 kB
/** * Class {@link UriUtil} encapsulates the utility methods related to URIs. */ export default abstract class UriUtil { /** * Sanitizes the given URI by extracting the query parameters and re-assembling * the URI with the query parameters sorted alphabetically by key. * @param {string} uri - The URI to be sanitized * @returns {string} - The sanitized URI */ static sanitizeUri(uri: string): string; /** * Generates a URI with the given query string appended to the end. * If the given URI does not already contain a query string, a new query string is added. * Otherwise, the given query string is appended to the existing query string. * @param {string} uri - The base URI * @param {string} qs - The query string to append * @returns {string} - The URI with the query string appended */ static generateUri(uri: string, qs: string): string; /** * Given a URI, returns the query parameters as a JSON object, or null if no query parameters are present * @param {string} uri - The URI with query parameters * @returns {Object} - The query parameters as a JSON object, or null if no query parameters are present */ static uriParams(uri: string): any; /** * Removes the query string from the given URI path. * * @param {any} path - The URI path from which the query string should be removed. * @returns {string} - The path without the query string, or the original path if no query string is present. */ static removeQueryString(path: any): any; /** * Returns true if the given URI has a base URL, false otherwise. * * A URI is considered to have a base URL if it starts with 'http://' or 'https://'. * * @param {string} uri - The URI to check for a base URL. * @returns {boolean} - True if the URI has a base URL, false otherwise. */ static hasBaseUrl(uri: string): boolean; }