@yeepay/yop-typescript-sdk
Version:
TypeScript SDK for interacting with YOP (YeePay Open Platform)
40 lines (39 loc) • 1.47 kB
TypeScript
import { Request } from './types.js';
export declare class HttpUtils {
/**
* Normalizes a value by encoding special characters according to RFC 3986
*
* 严格遵循 RFC 3986 标准进行 URL 编码:
* - 保留非保留字符(unreserved characters): [A-Za-z0-9-_.~]
* - 空格编码为 %20 (不是 +)
* - + 编码为 %2B
* - * 编码为 %2A
* - ~ 不编码(是非保留字符)
* - 其他字符按 UTF-8 编码后转为 %XX 格式
*
* @param value - The value to normalize
* @returns Normalized string according to RFC 3986
*/
static normalize(value: string | number | boolean | undefined | null): string;
/**
* Encodes parameters in a request
* @param req - The request containing parameters
* @returns Encoded parameters
*/
static encodeParams(req: Request): Record<string, string>;
/**
* Checks if a string starts with a substring
* @param haystack - The string to check
* @param needle - The substring to look for
* @returns True if haystack starts with needle
*/
static startsWith(haystack: string, needle: string): boolean;
/**
* Checks if a string ends with a substring
* @param haystack - The string to check
* @param needle - The substring to look for
* @returns True if haystack ends with needle
*/
static endsWith(haystack: string, needle: string): boolean;
}
export default HttpUtils;