axios-miniprogram/src/helpers/combineURL.ts

6 lines
208 B
TypeScript
Raw Normal View History

const combineRE = /(^|[^:])\/{2,}/g;
2023-04-07 08:47:54 +08:00
const removeRE = /\/$/;
2023-04-01 23:11:55 +08:00
export function combineURL(baseURL: string, url: string): string {
2023-04-07 08:47:54 +08:00
return `${baseURL}/${url}`.replace(combineRE, '$1/').replace(removeRE, '');
2023-03-28 21:32:54 +08:00
}