1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 520x 520x 520x 520x 520x 520x 520x 520x 520x 44x 44x 44x 97x 55x 42x 40x 2x 2x 44x 44x 44x 44x 2x 8x 8x 9x 1x 96x 95x 83x 83x 83x 83x 55x 40x 40x 44x 44x 44x 44x 42x 42x 42x 97x 97x 1809x 1809x 1809x 1809x 122x 122x 268x 268x 268x 783x 783x 286x 497x 24x 244x 268x 268x 798x 268x 268x 501x 363x 363x 363x 363x 289x 74x 363x 363x 289x 363x 501x 501x 501x 501x 65x 65x 65x 65x 501x 69x 69x 69x 501x 502x 57x 57x 57x 57x 57x 502x 39x 39x 39x 502x 520x 520x 520x 520x 520x 520x 520x 91x 520x 391x 391x 520x 263x 263x 21x 499x 529x 529x 529x 499x 499x 499x 499x 499x 499x 499x 83x 3x 80x 80x 27x 53x 53x 53x 53x 53x 120x 120x 120x 120x 120x 120x 120x 53x 120x 93x 120x 120x 83x 83x 83x 83x 7x 7x 16x 16x 83x 743x 520x 520x 1202x 6x | import ns from '../namespace'; ns.namespace('ima.router'); /** * Regular expression matching all control characters used in regular * expressions. The regular expression is used to match these characters in * path expressions and replace them appropriately so the path expression can * be compiled to a regular expression. * * @const * @type {RegExp} */ const CONTROL_CHARACTERS_REGEXP = /[\\.+*?^$[\](){}/'#]/g; /** * Regular expression used to match and remove the starting and trailing * forward slashes from a path expression or a URL path. * * @const * @type {RegExp} */ const LOOSE_SLASHES_REGEXP = /^\/|\/$/g; /** * Regular expression used to match the parameter names from a path expression. * * @const * @type {RegExp} */ const PARAMS_REGEXP_UNIVERSAL = /:\??([\w-]+)/g; /** * Regular expression used to match the required parameter names from a path expression. * * @const * @type {RegExp} */ const PARAMS_REGEXP_REQUIRED = /(?:^|\\\/):([a-z0-9]+)(?=\\\/|$)/gi; /** * Regular expression used to separate a camelCase parameter name * * @const * @type {RegExp} */ const PARAMS_REGEXP_CORE_NAME = /[a-z0-9]+/i; /** * Regular expression used to match start of parameter names from a path expression. * * @const * @type {String} */ const PARAMS_START_PATTERN = '(^|/|[_-])'; /** * Regular expression used to match end of parameter names from a path expression. * * @const * @type {String} */ const PARAMS_END_PATTERN = '[/?_-]|$'; /** * Regular expression used to never match the parameter names from a path expression. * It's used for wrong parameters order (optional vs. required ones) * * @const * @type {RegExp} */ const PARAMS_NEVER_MATCH_REGEXP = /$a/; /** * Regular expression used to match all main parameter names from a path expression. * * @const * @type {RegExp} */ const PARAMS_MAIN_REGEXP = /(?:\\\/|^):\\\?([a-z0-9]+)(?=\\\/|$)|(?:^|\\\/):([a-z0-9]+)(?=\\\/|$)/gi; /** * Regular expression used to match the required subparameter names from a path expression. * (e.g. for path '/:paramA-:paramB/:nextParam' are subparametres 'paramA' and 'paramB') * * @const * @type {Object<String, RegExp>} */ const SUBPARAMS_REQUIRED_REGEXP = { LAST: /([_-]{1})((\w-)?:[a-z0-9]+)(?=\\\/|$)/gi, OTHERS: /(:[a-z0-9]+)(?=[_-]{1})/gi }; /** * Regular expression used to match the optional parameter names from a path expression. * * @const * @type {Object<String, RegExp>} */ const SUBPARAMS_OPT_REGEXP = { LAST: /([_-]{1}(\w-)?:\\\?[a-z0-9]+)(?=\\\/|$)/gi, OTHERS: /(:\\\?[a-z0-9]+)(?=[_-]{1}(\w-)?)/gi }; /** * Regular expression used to match the parameter names from a path expression. * * @const * @type {RegExp} */ const PARAMS_REGEXP_OPT = /(?:^:\\\?([a-z0-9]+)(?=\\\/|$))|(?:(\\\/):\\\?([a-z0-9]+)(?=\\\/|$))/gi; // last part: |(?::\\\?([a-z0-9]+)(?=\\\/|$)) /** * Utility for representing and manipulating a single route in the router's * configuration. */ export default class Route { /** * Initializes the route. * * @param {string} name The unique name of this route, identifying it among * the rest of the routes in the application. * @param {string} pathExpression A path expression specifying the URL path * part matching this route (must not contain a query string), * optionally containing named parameter placeholders specified as * {@code :parameterName}. * @param {string} controller The full name of Object Container alias * identifying the controller associated with this route. * @param {string} view The full name or Object Container alias identifying * the view class associated with this route. * @param {{ * onlyUpdate: ( * boolean| * function( * (string|function(new: Controller, ...*)), * (string|function( * new: React.Component, * Object<string, *>, * ?Object<string, *> * )) * ): boolean * )=, * autoScroll: boolean=, * allowSPA: boolean=, * documentView: ?AbstractDocumentView= * }} options The route additional options. */ constructor(name, pathExpression, controller, view, options) { /** * The unique name of this route, identifying it among the rest of the * routes in the application. * * @type {string} */ this._name = name; /** * The original URL path expression from which this route was created. * * @type {string} */ this._pathExpression = pathExpression; /** * The full name of Object Container alias identifying the controller * associated with this route. * * @type {string} */ this._controller = controller; /** * The full name or Object Container alias identifying the view class * associated with this route. * * @type {React.Component} */ this._view = view; /** * The route additional options. * * @type {{ * onlyUpdate: ( * boolean| * function( * (string|function(new: Controller, ...*)), * (string|function( * new: React.Component, * Object<string, *>, * ?Object<string, *> * )) * ): boolean * ), * autoScroll: boolean, * allowSPA: boolean, * documentView: ?function(new: AbstractDocumentView), * managedRootView: ?function(new: React.Component) * }} */ this._options = Object.assign( { onlyUpdate: false, autoScroll: true, allowSPA: true, documentView: null, managedRootView: null }, options ); /** * The path expression with the trailing slashes trimmed. * * @type {string} */ this._trimmedPathExpression = this._getTrimmedPath(pathExpression); /** * The names of the parameters in this route. * * @type {string[]} */ this._parameterNames = this._getParameterNames(pathExpression); /** * Set to {@code true} if this route contains parameters in its path. * * @type {boolean} */ this._hasParameters = !!this._parameterNames.length; /** * A regexp used to match URL path against this route and extract the * parameter values from the matched URL paths. * * @type {RegExp} */ this._matcher = this._compileToRegExp(this._trimmedPathExpression); } /** * Creates the URL and query parts of a URL by substituting the route's * parameter placeholders by the provided parameter value. * * The extraneous parameters that do not match any of the route's * placeholders will be appended as the query string. * * @param {Object<string, (number|string)>=} [params={}] The route * parameter values. * @return {string} Path and, if necessary, query parts of the URL * representing this route with its parameters replaced by the * provided parameter values. */ toPath(params = {}) { let path = this._pathExpression; let query = []; for (let paramName of Object.keys(params)) { if (this._isRequiredParamInPath(path, paramName)) { path = this._substituteRequiredParamInPath( path, paramName, params[paramName] ); } else if (this._isOptionalParamInPath(path, paramName)) { path = this._substituteOptionalParamInPath( path, paramName, params[paramName] ); } else { const pair = [paramName, params[paramName]]; query.push(pair.map(encodeURIComponent).join('=')); } } path = this._cleanUnusedOptionalParams(path); path = query.length ? path + '?' + query.join('&') : path; path = this._getTrimmedPath(path); return path; } /** * Returns the unique identifying name of this route. * * @return {string} The name of the route, identifying it. */ getName() { return this._name; } /** * Returns the full name of the controller to use when this route is * matched by the current URL, or an Object Container-registered alias of * the controller. * * @return {string} The name of alias of the controller. */ getController() { return this._controller; } /** * Returns the full name of the view class or an Object * Container-registered alias for the view class, representing the view to * use when this route is matched by the current URL. * * @return {string} The name or alias of the view class. */ getView() { return this._view; } /** * Return route additional options. * * @return {{ * onlyUpdate: ( * boolean| * function( * (string|function(new: Controller, ...*)), * (string|function( * new: React.Component, * Object<string, *>, * ?Object<string, *> * )) * ): boolean * ), * autoScroll: boolean, * allowSPA: boolean, * documentView: ?AbstractDocumentView * }} */ getOptions() { return this._options; } /** * Returns the path expression, which is the parametrized pattern matching * the URL paths matched by this route. * * @return {string} The path expression. */ getPathExpression() { return this._pathExpression; } /** * Tests whether the provided URL path matches this route. The provided * path may contain the query. * * @param {string} path The URL path. * @return {boolean} {@code true} if the provided path matches this route. */ matches(path) { let trimmedPath = this._getTrimmedPath(path); return this._matcher.test(trimmedPath); } /** * Extracts the parameter values from the provided path. The method * extracts both the in-path parameters and parses the query, allowing the * query parameters to override the in-path parameters. * * The method returns an empty hash object if the path does not match this * route. * * @param {string} path * @return {Object<string, ?string>} Map of parameter names to parameter * values. */ extractParameters(path) { let trimmedPath = this._getTrimmedPath(path); let parameters = this._getParameters(trimmedPath); let query = this._getQuery(trimmedPath); return Object.assign({}, parameters, query); } /** * Replace required parameter placeholder in path with parameter value. * * @param {string} path * @param {string} paramName * @param {string} paramValue * @return {string} New path. */ _substituteRequiredParamInPath(path, paramName, paramValue) { return path.replace( new RegExp(`${PARAMS_START_PATTERN}:${paramName}(${PARAMS_END_PATTERN})`), paramValue ? '$1' + encodeURIComponent(paramValue) + '$2' : '' ); } /** * Replace optional param placeholder in path with parameter value. * * @param {string} path * @param {string} paramName * @param {string} paramValue * @return {string} New path. */ _substituteOptionalParamInPath(path, paramName, paramValue) { const paramRegexp = `${PARAMS_START_PATTERN}:\\?${paramName}(${PARAMS_END_PATTERN})`; return path.replace( new RegExp(paramRegexp), paramValue ? '$1' + encodeURIComponent(paramValue) + '$2' : '/' ); } /** * Remove unused optional param placeholders in path. * * @param {string} path * @return {string} New path. */ _cleanUnusedOptionalParams(path) { let replacedPath = path; // remove last subparameters replacedPath = replacedPath.replace(/([_-])(:\?([a-z0-9]+))(?=\/)/gi, '$1'); // remove parameters replacedPath = replacedPath.replace( /(\/:\?([a-z0-9]+))|(:\?([a-z0-9]+)\/?)/gi, '' ); return replacedPath; } /** * Returns true, if paramName is placed in path. * * @param {string} path * @param {string} paramName * @return {boolean} */ _isOptionalParamInPath(path, paramName) { const paramRegexp = `${PARAMS_START_PATTERN}:\\?${paramName}(?:${PARAMS_END_PATTERN})`; let regexp = new RegExp(paramRegexp); return regexp.test(path); } /** * Returns true, if paramName is placed in path and it's required. * * @param {string} path * @param {string} paramName * @return {boolean} */ _isRequiredParamInPath(path, paramName) { let regexp = new RegExp(`:${paramName}`); return regexp.test(path); } /** * Extract clear parameter name, e.q. '?name' or 'name' * * @param {string} rawParam * @return {string} */ _getClearParamName(rawParam) { const regExpr = /\??[a-z0-9]+/i; const paramMatches = rawParam.match(regExpr); const param = paramMatches ? paramMatches[0] : ''; return param; } /** * Get pattern for subparameter. * * @param {string} delimeter Parameters delimeter * @return {string} */ _getSubparamPattern(delimeter) { const pattern = `([^${delimeter}]+)`; return pattern; } /** * Check if all optional params are below required ones * * @param {array<string>} allMainParams * @return {boolean} */ _checkOptionalParamsOrder(allMainParams) { let optionalLastId = -1; const count = allMainParams.length; for (let idx = 0; idx < count; idx++) { const item = allMainParams[idx]; if (item.substr(0, 1) === '?') { optionalLastId = idx; } else { if (optionalLastId > -1 && idx > optionalLastId) { return false; } } } return true; } /** * Check if main parametres have correct order. * It means that required param cannot follow optional one. * * @param {string} clearedPathExpr The cleared URL path (removed first and last slash, ...). * @return {Bool} Returns TRUE if order is correct. */ _checkParametersOrder(clearedPathExpr) { const mainParamsMatches = clearedPathExpr.match(PARAMS_MAIN_REGEXP) || []; const allMainParamsCleared = mainParamsMatches.map(paramExpr => this._getClearParamName(paramExpr) ); const isCorrectParamOrder = this._checkOptionalParamsOrder( allMainParamsCleared ); return isCorrectParamOrder; } /** * Convert main optional parameters to capture sequences * * @param {string} path The URL path. * @param {array<string>} optionalParams List of main optimal parameter expressions * @return {string} RegExp pattern. */ _replaceOptionalParametersInPath(path, optionalParams) { const pattern = optionalParams.reduce((path, paramExpr, idx, matches) => { const lastIdx = matches.length - 1; const hasSlash = paramExpr.substr(0, 2) === '\\/'; let separator = ''; if (idx === 0) { separator = '(?:' + (hasSlash ? '/' : ''); } else { separator = hasSlash ? '/?' : ''; } let regExpr = separator + `([^/?]+)?(?=/|$)?`; if (idx === lastIdx) { regExpr += ')?'; } return path.replace(paramExpr, regExpr); }, path); return pattern; } /** * Convert required subparameters to capture sequences * * @param {string} path The URL path (route definition). * @param {string} clearedPathExpr The original cleared URL path. * @return {string} RegExp pattern. */ _replaceRequiredSubParametersInPath(path, clearedPathExpr) { const requiredSubparamsOthers = clearedPathExpr.match(SUBPARAMS_REQUIRED_REGEXP.OTHERS) || []; const requiredSubparamsLast = clearedPathExpr.match(SUBPARAMS_REQUIRED_REGEXP.LAST) || []; path = requiredSubparamsOthers.reduce((pattern, paramExpr) => { const paramIdx = pattern.indexOf(paramExpr) + paramExpr.length; const delimeter = pattern.substr(paramIdx, 1); const regExpr = this._getSubparamPattern(delimeter); return pattern.replace(paramExpr, regExpr); }, path); path = requiredSubparamsLast.reduce((pattern, rawParamExpr) => { const paramExpr = rawParamExpr.substr(1); const regExpr = '([^/?]+)'; return pattern.replace(paramExpr, regExpr); }, path); return path; } /** * Convert optional subparameters to capture sequences * * @param {string} path The URL path (route definition). * @param {array<string>} optionalSubparamsOthers List of all subparam. expressions but last ones * @param {array<string>} optionalSubparamsLast List of last subparam. expressions * @return {string} RegExp pattern. */ _replaceOptionalSubParametersInPath( path, optionalSubparamsOthers, optionalSubparamsLast ) { path = optionalSubparamsOthers.reduce((pattern, paramExpr) => { const paramIdx = pattern.indexOf(paramExpr) + paramExpr.length; const delimeter = pattern.substr(paramIdx, 1); const paramPattern = this._getSubparamPattern(delimeter); const regExpr = paramPattern + '?'; return pattern.replace(paramExpr, regExpr); }, path); path = optionalSubparamsLast.reduce((pattern, rawParamExpr) => { const paramExpr = rawParamExpr.substr(1); const regExpr = '([^/?]+)?'; return pattern.replace(paramExpr, regExpr); }, path); return path; } /** * Compiles the path expression to a regular expression that can be used * for easier matching of URL paths against this route, and extracting the * path parameter values from the URL path. * * @param {string} pathExpression The path expression to compile. * @return {RegExp} The compiled regular expression. */ _compileToRegExp(pathExpression) { const clearedPathExpr = pathExpression .replace(LOOSE_SLASHES_REGEXP, '') .replace(CONTROL_CHARACTERS_REGEXP, '\\$&'); const requiredMatches = clearedPathExpr.match(PARAMS_REGEXP_REQUIRED) || []; const optionalMatches = clearedPathExpr.match(PARAMS_REGEXP_OPT) || []; const optionalSubparamsLast = clearedPathExpr.match(SUBPARAMS_OPT_REGEXP.LAST) || []; const optionalSubparamsOthers = clearedPathExpr.match(SUBPARAMS_OPT_REGEXP.OTHERS) || []; const optionalSubparams = [ ...optionalSubparamsOthers, ...optionalSubparamsLast ]; const optionalSubparamsCleanNames = optionalSubparams.map(paramExpr => { return this._getClearParamName(paramExpr); }); const optionalParams = optionalMatches.filter(paramExpr => { const param = this._getClearParamName(paramExpr); return !optionalSubparamsCleanNames.includes(param); }); if (!!requiredMatches.length && !!optionalParams.length) { const isCorrectParamOrder = this._checkParametersOrder(clearedPathExpr); if (!isCorrectParamOrder) { return PARAMS_NEVER_MATCH_REGEXP; } } // convert required parameters to capture sequences let pattern = requiredMatches.reduce((pattern, rawParamExpr) => { const paramExpr = ':' + this._getClearParamName(rawParamExpr); const regExpr = '([^/?]+)'; return pattern.replace(paramExpr, regExpr); }, clearedPathExpr); pattern = this._replaceOptionalParametersInPath(pattern, optionalParams); pattern = this._replaceRequiredSubParametersInPath( pattern, clearedPathExpr ); pattern = this._replaceOptionalSubParametersInPath( pattern, optionalSubparamsOthers, optionalSubparamsLast ); // add path root pattern = '^\\/' + pattern; // add query parameters matcher let pairPattern = '[^=&;]*(?:=[^&;]*)?'; pattern += `(?:\\?(?:${pairPattern})(?:[&;]${pairPattern})*)?$`; return new RegExp(pattern); } /** * Parses the provided path and extract the in-path parameters. The method * decodes the parameters and returns them in a hash object. * * @param {string} path The URL path. * @return {Object<string, string>} The parsed path parameters. */ _getParameters(path) { if (!this._hasParameters) { return {}; } let parameterValues = path.match(this._matcher); if (!parameterValues) { return {}; } parameterValues.shift(); // remove the match on whole path, and other parts return this._extractParameters(parameterValues); } /** * Extract parameters from given path. * * @param {string[]} parameterValues * @return {Object<string, ?string>} Params object. */ _extractParameters(parameterValues) { let parameters = {}; const parametersCount = this._parameterNames.length; // Cycle for names and values from last to 0 for (let i = parametersCount - 1; i >= 0; i--) { let [rawName, rawValue] = [this._parameterNames[i], parameterValues[i]]; let cleanParamName = this._cleanOptParamName(rawName); const matchesName = cleanParamName.match(PARAMS_REGEXP_CORE_NAME); const currentCoreName = matchesName ? matchesName[0] : ''; Eif (currentCoreName) { const value = this._decodeURIParameter(rawValue); parameters[currentCoreName] = value; } } return parameters; } /** * Decoding parameters. * * @param {string} parameterValue * @return {string} decodedValue */ _decodeURIParameter(parameterValue) { let decodedValue; if (parameterValue) { decodedValue = decodeURIComponent(parameterValue); } return decodedValue; } /** * Returns optional param name without "?" * * @param {string} paramName Full param name with "?" * @return {string} Strict param name without "?" */ _cleanOptParamName(paramName) { return paramName.replace('?', ''); } /** * Checks if parameter is optional or not. * * @param {string} paramName * @return {boolean} return true if is optional, otherwise false */ _isParamOptional(paramName) { return /\?.+/.test(paramName); } /** * Extracts and decodes the query parameters from the provided URL path and * query. * * @param {string} path The URL path, including the optional query string * (if any). * @return {Object<string, ?string>} Parsed query parameters. */ _getQuery(path) { let query = {}; let queryStart = path.indexOf('?'); let hasQuery = queryStart > -1 && queryStart !== path.length - 1; if (hasQuery) { let pairs = path.substring(queryStart + 1).split(/[&;]/); for (let parameterPair of pairs) { let pair = parameterPair.split('='); query[decodeURIComponent(pair[0])] = pair.length > 1 ? decodeURIComponent(pair[1]) : true; } } return query; } /** * Trims the trailing forward slash from the provided URL path. * * @param {string} path The path to trim. * @return {string} Trimmed path. */ _getTrimmedPath(path) { return `/${path.replace(LOOSE_SLASHES_REGEXP, '')}`; } /** * Extracts the parameter names from the provided path expression. * * @param {string} pathExpression The path expression. * @return {string[]} The names of the parameters defined in the provided * path expression. */ _getParameterNames(pathExpression) { let rawNames = pathExpression.match(PARAMS_REGEXP_UNIVERSAL) || []; return rawNames.map(rawParameterName => { return rawParameterName.substring(1).replace('?', ''); }); } } ns.ima.router.Route = Route; |