UNPKG

@aptpod/iscp-ts

Version:

iSCP 2.0 client library for TypeScript

16 lines 705 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.joinUrl = void 0; 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}`; }; exports.joinUrl = joinUrl; //# sourceMappingURL=index.js.map