MCPcopy
hub / github.com/tighten/ziggy / _unresolve

Method _unresolve

src/js/Router.js:78–94  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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();

Callers 4

currentMethod · 0.95
paramsMethod · 0.95
routeParamsMethod · 0.95
queryParamsMethod · 0.95

Calls 3

_currentUrlMethod · 0.95
_locationMethod · 0.95
matchesUrlMethod · 0.80

Tested by

no test coverage detected