@aptpod/iscp-ts
Version:
iSCP 2.0 client library for TypeScript
12 lines • 582 B
JavaScript
export const joinUrl = (params) => {
const { schema, address, pathname } = params;
let adjustedPathname = pathname;
// pathname が一文字以上かつ 先頭に "/" がない場合は"/"を付与する"
if (adjustedPathname.length > 0 && !adjustedPathname.startsWith('/')) {
adjustedPathname = `/${adjustedPathname}`;
}
// pathname で / が連続で存在する場合は1つにまとめる
adjustedPathname = adjustedPathname.replace(/\/{2,}/g, '/');
return `${schema}://${address}${adjustedPathname}`;
};
//# sourceMappingURL=index.js.map