UNPKG

bugyo-cloud-client

Version:
29 lines 999 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractUserCode = exports.produceUrl = void 0; const url_1 = require("url"); const bugyo_cloud_client_1 = require("../bugyo-cloud-client"); const config_1 = require("../config"); /** * EndPointに応じたURLを返します * * @param endpoint * @param param */ const produceUrl = (endpoint, param) => { var _a; return config_1.URL_TEMPLATE[endpoint](param.tenantCode, (_a = param.userCode) !== null && _a !== void 0 ? _a : ""); }; exports.produceUrl = produceUrl; /** * URLのパスの2番目の要素を返します。 * * @param url */ const extractUserCode = (url) => { const urlobj = new url_1.URL(url); const parts = urlobj.pathname.split("/"); if (parts.length < 3 || parts[2] === "") { throw new bugyo_cloud_client_1.BugyoCloudClientError(`Unexpected url : ${url}`); } return parts[2]; }; exports.extractUserCode = extractUserCode; //# sourceMappingURL=url-utils.js.map