UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

56 lines 2.03 kB
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; import { urlCombine } from "@aurigma/design-atoms-model/Utils/Utils"; export function addUrlParameter(startUrl, name, value) { var separator = startUrl.indexOf('?') == -1 ? '?' : '&'; return startUrl + separator + encodeURIComponent(name) + '=' + encodeURIComponent(value); } export function buildUrl(baseUrl, endpoint, endpointParams, queryParams) { if (endpointParams) for (var item in endpointParams) endpoint = endpoint.replace("{" + item + "}", encodeURIComponent(endpointParams[item])); var url = urlCombine(baseUrl, endpoint); if (queryParams) for (var item in queryParams) url = addUrlParameter(url, item, queryParams[item]); return url; } export function shouldEncodeUrl(url) { try { var _a = __read(url.split('?'), 2), route = _a[0], query = _a[1]; if (decodeURIComponent(route) !== route) { return false; } if (query) { var params = query.split('&'); for (var item in params) { var _b = __read(params[item].split('='), 2), key = _b[0], value = _b[1]; if (key && decodeURIComponent(key) !== key) { return false; } if (value && decodeURIComponent(value) !== value) { return false; } } } return true; } catch (e) { return false; } } //# sourceMappingURL=UrlUtils.js.map