mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 10:53:44 +08:00
1 line
46 KiB
Plaintext
1 line
46 KiB
Plaintext
{"version":3,"file":"route-recognizer.js","sources":["route-recognizer/util.ts","route-recognizer/dsl.ts","route-recognizer/normalizer.ts","route-recognizer.ts"],"sourcesContent":["const createObject = Object.create;\nexport function createMap<T>() {\n const map: { [key: string]: T | undefined } = createObject(null);\n map[\"__\"] = undefined;\n delete map[\"__\"];\n return map;\n}\n","import { createMap } from \"./util\";\n\nexport interface Delegate {\n contextEntered?(context: string, route: MatchDSL): void;\n willAddRoute?(context: string | undefined, route: string): string;\n}\n\nexport type Opaque = {} | void | null | undefined;\n\nexport interface Route {\n path: string;\n handler: Opaque;\n queryParams?: string[];\n}\n\nexport interface RouteRecognizer {\n delegate: Delegate | undefined;\n add(routes: Route[]): void;\n}\n\nexport interface MatchCallback {\n (match: MatchDSL): void;\n}\n\nexport interface MatchDSL {\n (path: string): ToDSL;\n (path: string, callback: MatchCallback): void;\n}\n\nexport interface ToDSL {\n to(name: string, callback?: MatchCallback): void;\n}\n\nclass Target implements ToDSL {\n path: string;\n matcher: Matcher;\n delegate: Delegate | undefined;\n\n constructor(path: string, matcher: Matcher, delegate: Delegate | undefined) {\n this.path = path;\n this.matcher = matcher;\n this.delegate = delegate;\n }\n\n to(target: string, callback: MatchCallback) {\n let delegate = this.delegate;\n\n if (delegate && delegate.willAddRoute) {\n target = delegate.willAddRoute(this.matcher.target, target);\n }\n\n this.matcher.add(this.path, target);\n\n if (callback) {\n if (callback.length === 0) { throw new Error(\"You must have an argument in the function passed to `to`\"); }\n this.matcher.addChild(this.path, target, callback, this.delegate);\n }\n }\n}\n\nexport class Matcher {\n routes: {\n [path: string]: string | undefined;\n };\n children: {\n [path: string]: Matcher | undefined;\n };\n target: string | undefined;\n\n constructor(target?: string) {\n this.routes = createMap<string>();\n this.children = createMap<Matcher>();\n this.target = target;\n }\n\n add(path: string, target: string) {\n this.routes[path] = target;\n }\n\n addChild(path: string, target: string, callback: MatchCallback, delegate: Delegate | undefined) {\n let matcher = new Matcher(target);\n this.children[path] = matcher;\n\n let match = generateMatch(path, matcher, delegate);\n\n if (delegate && delegate.contextEntered) {\n delegate.contextEntered(target, match);\n }\n\n callback(match);\n }\n}\n\nfunction generateMatch(startingPath: string, matcher: Matcher, delegate: Delegate | undefined): MatchDSL {\n function match(path: string): ToDSL;\n function match(path: string, callback: MatchCallback): void;\n function match(path: string, callback?: MatchCallback): ToDSL | void {\n let fullPath = startingPath + path;\n if (callback) {\n callback(generateMatch(fullPath, matcher, delegate));\n } else {\n return new Target(fullPath, matcher, delegate);\n }\n };\n return match;\n}\n\nfunction addRoute(routeArray: Route[], path: string, handler: any) {\n let len = 0;\n for (let i = 0; i < routeArray.length; i++) {\n len += routeArray[i].path.length;\n }\n\n path = path.substr(len);\n let route = { path: path, handler: handler };\n routeArray.push(route);\n}\n\nfunction eachRoute<T>(baseRoute: Route[], matcher: Matcher, callback: (this: T, routes: Route[]) => void, binding: T) {\n let routes = matcher.routes;\n let paths = Object.keys(routes);\n for (let i = 0; i < paths.length; i++) {\n let path = paths[i];\n let routeArray = baseRoute.slice();\n addRoute(routeArray, path, routes[path]);\n let nested = matcher.children[path];\n if (nested) {\n eachRoute(routeArray, nested, callback, binding);\n } else {\n callback.call(binding, routeArray);\n }\n }\n}\n\nexport default function <T extends RouteRecognizer>(this: T, callback: MatchCallback, addRouteCallback?: (routeRecognizer: T, routes: Route[]) => void) {\n let matcher = new Matcher();\n\n callback(generateMatch(\"\", matcher, this.delegate));\n\n eachRoute([], matcher, function(routes: Route[]) {\n if (addRouteCallback) { addRouteCallback(this, routes); }\n else { this.add(routes); }\n }, this);\n}\n","// Normalizes percent-encoded values in `path` to upper-case and decodes percent-encoded\n// values that are not reserved (i.e., unicode characters, emoji, etc). The reserved\n// chars are \"/\" and \"%\".\n// Safe to call multiple times on the same path.\nexport function normalizePath(path: string): string {\n return path.split(\"/\")\n .map(normalizeSegment)\n .join(\"/\");\n}\n\n// We want to ensure the characters \"%\" and \"/\" remain in percent-encoded\n// form when normalizing paths, so replace them with their encoded form after\n// decoding the rest of the path\nconst SEGMENT_RESERVED_CHARS = /%|\\//g;\nexport function normalizeSegment(segment: string) {\n if (segment.length < 3 || segment.indexOf(\"%\") === -1) return segment;\n return decodeURIComponent(segment).replace(SEGMENT_RESERVED_CHARS, encodeURIComponent);\n}\n\n// We do not want to encode these characters when generating dynamic path segments\n// See https://tools.ietf.org/html/rfc3986#section-3.3\n// sub-delims: \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\"\n// others allowed by RFC 3986: \":\", \"@\"\n//\n// First encode the entire path segment, then decode any of the encoded special chars.\n//\n// The chars \"!\", \"'\", \"(\", \")\", \"*\" do not get changed by `encodeURIComponent`,\n// so the possible encoded chars are:\n// ['%24', '%26', '%2B', '%2C', '%3B', '%3D', '%3A', '%40'].\nconst PATH_SEGMENT_ENCODINGS = /%(?:2(?:4|6|B|C)|3(?:B|D|A)|40)/g;\n\nexport function encodePathSegment(str: string) {\n return encodeURIComponent(str).replace(PATH_SEGMENT_ENCODINGS, decodeURIComponent);\n}\n","import { createMap } from \"./route-recognizer/util\";\nimport map, { Delegate, Route, Opaque, MatchCallback } from \"./route-recognizer/dsl\";\nimport { normalizePath, normalizeSegment, encodePathSegment } from \"./route-recognizer/normalizer\";\nexport { Delegate, MatchCallback } from './route-recognizer/dsl';\n\nconst enum CHARS {\n ANY = -1,\n STAR = 42,\n SLASH = 47,\n COLON = 58\n}\n\nconst escapeRegex = /(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)/g;\n\nconst isArray = Array.isArray;\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction getParam(params: Params | null | undefined, key: string): string {\n if (typeof params !== \"object\" || params === null) {\n throw new Error(\"You must pass an object as the second argument to `generate`.\");\n }\n\n if (!hasOwnProperty.call(params, key)) {\n throw new Error(\"You must provide param `\" + key + \"` to `generate`.\");\n }\n\n let value = params[key];\n let str = typeof value === \"string\" ? value : \"\" + value;\n if (str.length === 0) {\n throw new Error(\"You must provide a param `\" + key + \"`.\");\n }\n return str;\n}\n\nconst enum SegmentType {\n Static = 0,\n Dynamic = 1,\n Star = 2,\n Epsilon = 4\n}\n\nconst enum SegmentFlags {\n Static = 2 << SegmentType.Static,\n Dynamic = 2 << SegmentType.Dynamic,\n Star = 2 << SegmentType.Star,\n Epsilon = 2 << SegmentType.Epsilon,\n Named = Dynamic | Star,\n Decoded = Dynamic,\n Counted = Static | Dynamic | Star\n}\n\nconst eachChar: ((segment: Segment, currentState: State) => State)[] = [];\neachChar[SegmentType.Static] = function (segment: Segment, currentState: State) {\n let state = currentState;\n let value = segment.value;\n for (let i = 0; i < value.length; i++) {\n let ch = value.charCodeAt(i);\n state = state.put(ch, false, false);\n }\n return state;\n};\neachChar[SegmentType.Dynamic] = function (_: Segment, currentState: State) {\n return currentState.put(CHARS.SLASH, true, true);\n};\neachChar[SegmentType.Star] = function (_: Segment, currentState: State) {\n return currentState.put(CHARS.ANY, false, true);\n};\neachChar[SegmentType.Epsilon] = function (_: Segment, currentState: State) {\n return currentState;\n};\n\nconst regex: ((segment: Segment) => string)[] = [];\nregex[SegmentType.Static] = function (segment: Segment) {\n return segment.value.replace(escapeRegex, \"\\\\$1\");\n};\nregex[SegmentType.Dynamic] = function () {\n return \"([^/]+)\";\n};\nregex[SegmentType.Star] = function () {\n return \"(.+)\";\n};\nregex[SegmentType.Epsilon] = function () {\n return \"\";\n};\n\nconst generate: ((segment: Segment, params?: Params | null) => string)[] = [];\ngenerate[SegmentType.Static] = function (segment: Segment) {\n return segment.value;\n};\ngenerate[SegmentType.Dynamic] = function (segment: Segment, params?: Params) {\n let value = getParam(params, segment.value);\n if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {\n return encodePathSegment(value);\n } else {\n return value;\n }\n};\ngenerate[SegmentType.Star] = function (segment: Segment, params?: Params) {\n return getParam(params, segment.value);\n};\ngenerate[SegmentType.Epsilon] = function () {\n return \"\";\n};\n\n// A Segment represents a segment in the original route description.\n// Each Segment type provides an `eachChar` and `regex` method.\n//\n// The `eachChar` method invokes the callback with one or more character\n// specifications. A character specification consumes one or more input\n// characters.\n//\n// The `regex` method returns a regex fragment for the segment. If the\n// segment is a dynamic of star segment, the regex fragment also includes\n// a capture.\n//\n// A character specification contains:\n//\n// * `validChars`: a String with a list of all valid characters, or\n// * `invalidChars`: a String with a list of all invalid characters\n// * `repeat`: true if the character specification can repeat\ninterface Segment {\n type: SegmentType;\n value: string;\n}\n\nexport interface Params {\n [key: string]: Opaque;\n [key: number]: Opaque;\n queryParams?: QueryParams | null;\n}\n\ninterface PopulatedParsedHandlers {\n names: string[];\n shouldDecodes: any[];\n}\n\nconst EmptyObject = Object.freeze({});\ntype EmptyObject = Readonly<{}>\n\nconst EmptyArray = Object.freeze([]) as ReadonlyArray<any>;\ntype EmptyArray = ReadonlyArray<any>;\n\ninterface EmptyParsedHandlers {\n names: EmptyArray;\n shouldDecodes: EmptyArray;\n}\n\ntype ParsedHandler = PopulatedParsedHandlers | EmptyParsedHandlers;\n\n// The `names` will be populated with the paramter name for each dynamic/star\n// segment. `shouldDecodes` will be populated with a boolean for each dyanamic/star\n// segment, indicating whether it should be decoded during recognition.\nfunction parse(segments: Segment[], route: string, types: [number, number, number]) {\n // normalize route as not starting with a \"/\". Recognition will\n // also normalize.\n if (route.length > 0 && route.charCodeAt(0) === CHARS.SLASH) { route = route.substr(1); }\n\n let parts = route.split(\"/\");\n let names: void | string[] = undefined;\n let shouldDecodes: void | any[] = undefined;\n\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n let flags: SegmentFlags = 0;\n let type: SegmentType = 0;\n\n if (part === \"\") {\n type = SegmentType.Epsilon;\n } else if (part.charCodeAt(0) === CHARS.COLON) {\n type = SegmentType.Dynamic;\n } else if (part.charCodeAt(0) === CHARS.STAR) {\n type = SegmentType.Star;\n } else {\n type = SegmentType.Static;\n }\n\n flags = 2 << type;\n\n if (flags & SegmentFlags.Named) {\n part = part.slice(1);\n names = names || [];\n names.push(part);\n\n shouldDecodes = shouldDecodes || [];\n shouldDecodes.push((flags & SegmentFlags.Decoded) !== 0);\n }\n\n if (flags & SegmentFlags.Counted) {\n types[type]++;\n }\n\n segments.push({\n type,\n value: normalizeSegment(part)\n });\n }\n\n return {\n names: names || EmptyArray,\n shouldDecodes: shouldDecodes || EmptyArray,\n } as ParsedHandler;\n}\n\nfunction isEqualCharSpec(spec: CharSpec, char: number, negate: boolean) {\n return spec.char === char && spec.negate === negate;\n}\n\ninterface EmptyHandler {\n handler: Opaque;\n names: EmptyArray;\n shouldDecodes: EmptyArray;\n}\n\ninterface PopulatedHandler {\n handler: Opaque;\n names: string [];\n shouldDecodes: boolean[];\n}\n\ntype Handler = EmptyHandler | PopulatedHandler;\n\n// A State has a character specification and (`charSpec`) and a list of possible\n// subsequent states (`nextStates`).\n//\n// If a State is an accepting state, it will also have several additional\n// properties:\n//\n// * `regex`: A regular expression that is used to extract parameters from paths\n// that reached this accepting state.\n// * `handlers`: Information on how to convert the list of captures into calls\n// to registered handlers with the specified parameters\n// * `types`: How many static, dynamic or star segments in this route. Used to\n// decide which route to use if multiple registered routes match a path.\n//\n// Currently, State is implemented naively by looping over `nextStates` and\n// comparing a character specification against a character. A more efficient\n// implementation would use a hash of keys pointing at one or more next states.\nclass State implements CharSpec {\n states: State[];\n id: number;\n negate: boolean;\n char: number;\n nextStates: number[] | number | null;\n pattern: string;\n _regex: RegExp | undefined;\n handlers: Handler[] | undefined;\n types: [number, number, number] | undefined;\n\n constructor(states: State[], id: number, char: number, negate: boolean, repeat: boolean) {\n this.states = states;\n this.id = id;\n this.char = char;\n this.negate = negate;\n this.nextStates = repeat ? id : null;\n this.pattern = \"\";\n this._regex = undefined;\n this.handlers = undefined;\n this.types = undefined;\n }\n\n regex(): RegExp {\n if (!this._regex) {\n this._regex = new RegExp(this.pattern);\n }\n return this._regex;\n }\n\n get(char: number, negate: boolean): State | void {\n let nextStates = this.nextStates;\n if (nextStates === null) return;\n if (isArray(nextStates)) {\n for (let i = 0; i < nextStates.length; i++) {\n let child = this.states[nextStates[i]];\n if (isEqualCharSpec(child, char, negate)) {\n return child;\n }\n }\n } else {\n let child = this.states[nextStates];\n if (isEqualCharSpec(child, char, negate)) {\n return child;\n }\n }\n }\n\n put(char: number, negate: boolean, repeat: boolean) {\n let state: State | void;\n\n // If the character specification already exists in a child of the current\n // state, just return that state.\n if (state = this.get(char, negate)) { return state; }\n\n // Make a new state for the character spec\n let states = this.states;\n state = new State(states, states.length, char, negate, repeat);\n states[states.length] = state;\n\n // Insert the new state as a child of the current state\n if (this.nextStates == null) {\n this.nextStates = state.id;\n } else if (isArray(this.nextStates)) {\n this.nextStates.push(state.id);\n } else {\n this.nextStates = [this.nextStates, state.id];\n }\n\n // Return the new state\n return state;\n }\n\n // Find a list of child states matching the next character\n match(ch: number): State[] {\n let nextStates = this.nextStates;\n if (!nextStates) return [];\n\n let returned: State[] = [];\n if (isArray(nextStates)) {\n for (let i = 0; i < nextStates.length; i++) {\n let child = this.states[nextStates[i]];\n\n if (isMatch(child, ch)) {\n returned.push(child);\n }\n }\n } else {\n let child = this.states[nextStates];\n if (isMatch(child, ch)) {\n returned.push(child);\n }\n }\n return returned;\n }\n}\n\nfunction isMatch(spec: CharSpec, char: number) {\n return spec.negate ? spec.char !== char && spec.char !== CHARS.ANY : spec.char === char || spec.char === CHARS.ANY;\n}\n\n// This is a somewhat naive strategy, but should work in a lot of cases\n// A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.\n//\n// This strategy generally prefers more static and less dynamic matching.\n// Specifically, it\n//\n// * prefers fewer stars to more, then\n// * prefers using stars for less of the match to more, then\n// * prefers fewer dynamic segments to more, then\n// * prefers more static segments to more\nfunction sortSolutions(states: State[]) {\n return states.sort(function(a, b) {\n let [ astatics, adynamics, astars ] = a.types || [0, 0, 0];\n let [ bstatics, bdynamics, bstars ] = b.types || [0, 0, 0];\n if (astars !== bstars) { return astars - bstars; }\n\n if (astars) {\n if (astatics !== bstatics) { return bstatics - astatics; }\n if (adynamics !== bdynamics) { return bdynamics - adynamics; }\n }\n\n if (adynamics !== bdynamics) { return adynamics - bdynamics; }\n if (astatics !== bstatics) { return bstatics - astatics; }\n\n return 0;\n });\n}\n\nfunction recognizeChar(states: State[], ch: number) {\n let nextStates: State[] = [];\n\n for (let i = 0, l = states.length; i < l; i++) {\n let state = states[i];\n\n nextStates = nextStates.concat(state.match(ch));\n }\n\n return nextStates;\n}\n\n\nexport interface QueryParams {\n [param: string]: any[] | any | null | undefined;\n}\n\nexport interface Result {\n handler: Opaque;\n params: Params;\n isDynamic: boolean;\n}\n\nexport interface Results extends ArrayLike<Result | undefined> {\n queryParams: QueryParams;\n slice(start?: number, end?: number): Result[];\n splice(start: number, deleteCount: number, ...items: Result[]): Result[];\n push(...results: Result[]): number;\n}\n\nclass RecognizeResults implements Results {\n queryParams: QueryParams;\n length = 0;\n [index: number]: Result | undefined;\n splice: (start: number, deleteCount: number, ...items: Result[]) => Result[];\n slice: (start?: number, end?: number) => Result[];\n push: (...results: Result[]) => number;\n\n constructor(queryParams?: QueryParams) {\n this.queryParams = queryParams || {};\n }\n};\n\nRecognizeResults.prototype.splice = Array.prototype.splice;\nRecognizeResults.prototype.slice = Array.prototype.slice;\nRecognizeResults.prototype.push = Array.prototype.push;\n\nfunction findHandler(state: State, originalPath: string, queryParams: QueryParams): Results {\n let handlers = state.handlers;\n let regex: RegExp = state.regex();\n if (!regex || !handlers) throw new Error(\"state not initialized\");\n let captures: RegExpMatchArray | null = originalPath.match(regex);\n let currentCapture = 1;\n let result = new RecognizeResults(queryParams);\n\n result.length = handlers.length;\n\n for (let i = 0; i < handlers.length; i++) {\n let handler = handlers[i];\n let names = handler.names;\n let shouldDecodes = handler.shouldDecodes;\n let params: EmptyObject | Params = EmptyObject;\n\n let isDynamic = false;\n\n if (names !== EmptyArray && shouldDecodes !== EmptyArray) {\n for (let j = 0; j < names.length; j++) {\n isDynamic = true;\n let name = names[j];\n let capture = captures && captures[currentCapture++];\n\n if (params === EmptyObject) {\n params = {};\n }\n\n if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS && shouldDecodes[j]) {\n (<Params>params)[name] = capture && decodeURIComponent(capture);\n } else {\n (<Params>params)[name] = capture;\n }\n }\n }\n\n result[i] = {\n handler: handler.handler,\n params,\n isDynamic\n };\n }\n\n return result;\n}\n\nfunction decodeQueryParamPart(part: string): string {\n // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1\n part = part.replace(/\\+/gm, \"%20\");\n let result;\n try {\n result = decodeURIComponent(part);\n } catch (error) {result = \"\"; }\n return result;\n}\n\ninterface NamedRoute {\n segments: Segment[];\n handlers: Handler[];\n}\n\nclass RouteRecognizer {\n private states: State[];\n private rootState: State;\n private names: {\n [name: string]: NamedRoute | undefined;\n } = createMap<NamedRoute>();\n map: (context: MatchCallback, addCallback?: (router: this, routes: Route[]) => void) => void;\n delegate: Delegate | undefined;\n\n constructor() {\n let states: State[] = [];\n let state = new State(states, 0, CHARS.ANY, true, false);\n states[0] = state;\n this.states = states;\n this.rootState = state;\n }\n\n static VERSION = \"0.3.4\";\n // Set to false to opt-out of encoding and decoding path segments.\n // See https://github.com/tildeio/route-recognizer/pull/55\n static ENCODE_AND_DECODE_PATH_SEGMENTS = true;\n static Normalizer = {\n normalizeSegment, normalizePath, encodePathSegment\n };\n\n add(routes: Route[], options?: { as: string }) {\n let currentState = this.rootState;\n let pattern = \"^\";\n let types: [number, number, number] = [0, 0, 0];\n let handlers: Handler[] = new Array(routes.length);\n let allSegments: Segment[] = [];\n\n let isEmpty = true;\n let j = 0;\n for (let i = 0; i < routes.length; i++) {\n let route = routes[i];\n let { names, shouldDecodes } = parse(allSegments, route.path, types);\n\n // preserve j so it points to the start of newly added segments\n for (; j < allSegments.length; j++) {\n let segment = allSegments[j];\n\n if (segment.type === SegmentType.Epsilon) { continue; }\n\n isEmpty = false;\n\n // Add a \"/\" for the new segment\n currentState = currentState.put(CHARS.SLASH, false, false);\n pattern += \"/\";\n\n // Add a representation of the segment to the NFA and regex\n currentState = eachChar[segment.type](segment, currentState);\n pattern += regex[segment.type](segment);\n }\n handlers[i] = {\n handler: route.handler,\n names,\n shouldDecodes\n };\n }\n\n if (isEmpty) {\n currentState = currentState.put(CHARS.SLASH, false, false);\n pattern += \"/\";\n }\n\n currentState.handlers = handlers;\n currentState.pattern = pattern + \"$\";\n currentState.types = types;\n\n let name: string | undefined;\n if (typeof options === \"object\" && options !== null && options.as) {\n name = options.as;\n }\n\n if (name) {\n // if (this.names[name]) {\n // throw new Error(\"You may not add a duplicate route named `\" + name + \"`.\");\n // }\n\n this.names[name] = {\n segments: allSegments,\n handlers\n };\n }\n }\n\n handlersFor(name: string) {\n let route = this.names[name];\n\n if (!route) { throw new Error(\"There is no route named \" + name); }\n\n let result = new Array(route.handlers.length);\n\n for (let i = 0; i < route.handlers.length; i++) {\n let handler = route.handlers[i];\n result[i] = handler;\n }\n\n return result;\n }\n\n hasRoute(name: string) {\n return !!this.names[name];\n }\n\n generate(name: string, params?: Params | null) {\n let route = this.names[name];\n let output = \"\";\n if (!route) { throw new Error(\"There is no route named \" + name); }\n\n let segments: Segment[] = route.segments;\n\n for (let i = 0; i < segments.length; i++) {\n let segment: Segment = segments[i];\n\n if (segment.type === SegmentType.Epsilon) {\n continue;\n }\n\n output += \"/\";\n output += generate[segment.type](segment, params);\n }\n\n if (output.charAt(0) !== \"/\") { output = \"/\" + output; }\n\n if (params && params.queryParams) {\n output += this.generateQueryString(params.queryParams);\n }\n\n return output;\n }\n\n generateQueryString(params: QueryParams) {\n let pairs: string[] = [];\n let keys: string[] = Object.keys(params);\n keys.sort();\n for (let i = 0; i < keys.length; i++) {\n let key = keys[i];\n let value = params[key];\n if (value == null) {\n continue;\n }\n let pair = encodeURIComponent(key);\n if (isArray(value)) {\n for (let j = 0; j < value.length; j++) {\n let arrayPair = key + \"[]\" + \"=\" + encodeURIComponent(value[j]);\n pairs.push(arrayPair);\n }\n } else {\n pair += \"=\" + encodeURIComponent(value);\n pairs.push(pair);\n }\n }\n\n if (pairs.length === 0) { return \"\"; }\n\n return \"?\" + pairs.join(\"&\");\n }\n\n parseQueryString(queryString: string): QueryParams {\n let pairs = queryString.split(\"&\");\n let queryParams: QueryParams = {};\n for (let i = 0; i < pairs.length; i++) {\n let pair = pairs[i].split(\"=\"),\n key = decodeQueryParamPart(pair[0]),\n keyLength = key.length,\n isArray = false,\n value;\n if (pair.length === 1) {\n value = \"true\";\n } else {\n // Handle arrays\n if (keyLength > 2 && key.slice(keyLength - 2) === \"[]\") {\n isArray = true;\n key = key.slice(0, keyLength - 2);\n if (!queryParams[key]) {\n queryParams[key] = [];\n }\n }\n value = pair[1] ? decodeQueryParamPart(pair[1]) : \"\";\n }\n if (isArray) {\n (<string[]>queryParams[key]).push(value);\n } else {\n queryParams[key] = value;\n }\n }\n return queryParams;\n }\n\n recognize(path: string): Results | undefined {\n let results: Results | undefined;\n let states: State[] = [ this.rootState ];\n let queryParams = {};\n let isSlashDropped = false;\n let hashStart = path.indexOf(\"#\");\n if (hashStart !== -1) {\n path = path.substr(0, hashStart);\n }\n\n let queryStart = path.indexOf(\"?\");\n if (queryStart !== -1) {\n let queryString = path.substr(queryStart + 1, path.length);\n path = path.substr(0, queryStart);\n queryParams = this.parseQueryString(queryString);\n }\n\n if (path.charAt(0) !== \"/\") { path = \"/\" + path; }\n let originalPath = path;\n\n if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {\n path = normalizePath(path);\n } else {\n path = decodeURI(path);\n originalPath = decodeURI(originalPath);\n }\n\n let pathLen = path.length;\n if (pathLen > 1 && path.charAt(pathLen - 1) === \"/\") {\n path = path.substr(0, pathLen - 1);\n originalPath = originalPath.substr(0, originalPath.length - 1);\n isSlashDropped = true;\n }\n\n for (let i = 0; i < path.length; i++) {\n states = recognizeChar(states, path.charCodeAt(i));\n if (!states.length) { break; }\n }\n\n let solutions: State[] = [];\n for (let i = 0; i < states.length; i++) {\n if (states[i].handlers) { solutions.push(states[i]); }\n }\n\n states = sortSolutions(solutions);\n\n let state = solutions[0];\n\n if (state && state.handlers) {\n // if a trailing slash was dropped and a star segment is the last segment\n // specified, put the trailing slash back\n if (isSlashDropped && state.pattern && state.pattern.slice(-5) === \"(.+)$\") {\n originalPath = originalPath + \"/\";\n }\n results = findHandler(state, originalPath, queryParams);\n }\n\n return results;\n }\n}\n\nRouteRecognizer.prototype.map = map;\n\nexport default RouteRecognizer;\n\ninterface CharSpec {\n negate: boolean;\n char: number;\n}\n"],"names":["const","let","this","child","i"],"mappings":";;;;;;AAAAA,IAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;AACnC;IACEA,IAAM,GAAG,GAAqC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjE,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACtB,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,GAAG,CAAC;CACZ;;AC2BD,6BAKc,IAAY,EAAE,OAAgB,EAAE,QAA8B;QACpE,CAAC,IAAI,GAAG,IAAI,CAAC;QACb,CAAC,OAAO,GAAG,OAAO,CAAC;QACnB,CAAC,QAAQ,GAAG,QAAQ,CAAC;CAC1B,CAAA;iBAED,EAAE,gBAAC,MAAc,EAAE,QAAuB;QACpC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEzB,QAAQ,IAAI,QAAQ,CAAC,YAAY,EAAE;cAC/B,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC7D;QAEG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEhC,QAAQ,EAAE;YACR,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;kBAAQ,IAAI,KAAK,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