* Get the parameters, values, and metadata from the given URL. * * @param {String} [url] - The URL to inspect, defaults to the current window URL. * @return {{ name: string, params: Object, query: Object, route: Route }}
(url)
| 76 | * @return {{ name: string, params: Object, query: Object, route: Route }} |
| 77 | */ |
| 78 | _unresolve(url) { |
| 79 | if (!url) { |
| 80 | url = this._currentUrl(); |
| 81 | } else if (this._config.absolute && url.startsWith('/')) { |
| 82 | // If we are using absolute URLs and a relative URL |
| 83 | // is passed, prefix the host to make it absolute |
| 84 | url = this._location().host + url; |
| 85 | } |
| 86 | |
| 87 | let matchedParams = {}; |
| 88 | const [name, route] = Object.entries(this._config.routes).find( |
| 89 | ([name, route]) => |
| 90 | (matchedParams = new Route(name, route, this._config).matchesUrl(url)), |
| 91 | ) || [undefined, undefined]; |
| 92 | |
| 93 | return { name, ...matchedParams, route }; |
| 94 | } |
| 95 | |
| 96 | _currentUrl() { |
| 97 | const { host, pathname, search } = this._location(); |
no test coverage detected