MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / parse

Function parse

06.Router/basic/js/vue.js:2627–2713  ·  view source on GitHub ↗

* Parse a string path into an array of segments * * @param {String} path * @return {Array|undefined}

(path)

Source from the content-addressed store, hash-verified

2625 */
2626
2627 function parse(path) {
2628 var keys = [];
2629 var index = -1;
2630 var mode = BEFORE_PATH;
2631 var subPathDepth = 0;
2632 var c, newChar, key, type, transition, action, typeMap;
2633
2634 var actions = [];
2635
2636 actions[PUSH] = function () {
2637 if (key !== undefined) {
2638 keys.push(key);
2639 key = undefined;
2640 }
2641 };
2642
2643 actions[APPEND] = function () {
2644 if (key === undefined) {
2645 key = newChar;
2646 } else {
2647 key += newChar;
2648 }
2649 };
2650
2651 actions[INC_SUB_PATH_DEPTH] = function () {
2652 actions[APPEND]();
2653 subPathDepth++;
2654 };
2655
2656 actions[PUSH_SUB_PATH] = function () {
2657 if (subPathDepth > 0) {
2658 subPathDepth--;
2659 mode = IN_SUB_PATH;
2660 actions[APPEND]();
2661 } else {
2662 subPathDepth = 0;
2663 key = formatSubPath(key);
2664 if (key === false) {
2665 return false;
2666 } else {
2667 actions[PUSH]();
2668 }
2669 }
2670 };
2671
2672 function maybeUnescapeQuote() {
2673 var nextChar = path[index + 1];
2674 if (mode === IN_SINGLE_QUOTE && nextChar === "'" || mode === IN_DOUBLE_QUOTE && nextChar === '"') {
2675 index++;
2676 newChar = '\\' + nextChar;
2677 actions[APPEND]();
2678 return true;
2679 }
2680 }
2681
2682 while (mode != null) {
2683 index++;
2684 c = path[index];

Callers 2

parsePathFunction · 0.70
setPathFunction · 0.70

Calls 3

formatSubPathFunction · 0.70
maybeUnescapeQuoteFunction · 0.70
getPathCharTypeFunction · 0.70

Tested by

no test coverage detected