UNPKG

@lattice/core

Version:
22 lines (21 loc) 921 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("../../../utils"); var UriMatcherRefiner = /** @class */ (function () { function UriMatcherRefiner() { } UriMatcherRefiner.refine = function (matcher) { if (matcher.uri.includes('/:')) { var uriArray = matcher.uri.split('/'); var newMatch_1; matcher = newMatch_1 = matcher; // construct newMatch newMatch_1.params = []; uriArray.forEach(function (v, i, a) { return v[0] == ':' && newMatch_1.params.push(v.substring(1, v.length)); }); newMatch_1.uri = uriArray.reduce(function (uri, value) { return value[0] == ':' ? utils_1.UriUtils.join(uri, ':') : utils_1.UriUtils.join(uri, value); }, '/'); } return matcher; }; return UriMatcherRefiner; }()); exports.UriMatcherRefiner = UriMatcherRefiner;