@tinkoff/router 0.1.74 → 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.js +8 -3
- package/lib/index.es.js +8 -3
- package/lib/index.js +8 -3
- package/lib/utils.d.ts +1 -1
- package/package.json +3 -3
package/lib/index.browser.js
CHANGED
|
@@ -366,7 +366,9 @@ class AbstractRouter {
|
|
|
366
366
|
pathname = makePath(currentRoute.path, { ...currentRoute.params, ...params });
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
if (isSameHost(resultUrl)) {
|
|
370
|
+
pathname = this.normalizePathname(pathname);
|
|
371
|
+
}
|
|
370
372
|
return convertRawUrl(rawAssignUrl(resultUrl, {
|
|
371
373
|
pathname,
|
|
372
374
|
search: url ? resultUrl.search : '',
|
|
@@ -770,8 +772,11 @@ class ClientRouter extends AbstractRouter {
|
|
|
770
772
|
// in case we didn't find any matched route just force hard page navigation
|
|
771
773
|
const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
|
|
772
774
|
const nextUrl = navigation.url.href;
|
|
773
|
-
|
|
774
|
-
|
|
775
|
+
const isNoSpaNavigation = navigation.from && !navigation.to;
|
|
776
|
+
// prevent redirect cycle on the same page,
|
|
777
|
+
// except cases when we run no-spa navigations,
|
|
778
|
+
// because we need hard reload in this cases
|
|
779
|
+
if (isNoSpaNavigation ? true : prevUrl !== nextUrl) {
|
|
775
780
|
if (navigation.replace) {
|
|
776
781
|
window.location.replace(nextUrl);
|
|
777
782
|
}
|
package/lib/index.es.js
CHANGED
|
@@ -366,7 +366,9 @@ class AbstractRouter {
|
|
|
366
366
|
pathname = makePath(currentRoute.path, { ...currentRoute.params, ...params });
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
if (isSameHost(resultUrl)) {
|
|
370
|
+
pathname = this.normalizePathname(pathname);
|
|
371
|
+
}
|
|
370
372
|
return convertRawUrl(rawAssignUrl(resultUrl, {
|
|
371
373
|
pathname,
|
|
372
374
|
search: url ? resultUrl.search : '',
|
|
@@ -1000,8 +1002,11 @@ class ClientRouter extends AbstractRouter {
|
|
|
1000
1002
|
// in case we didn't find any matched route just force hard page navigation
|
|
1001
1003
|
const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
|
|
1002
1004
|
const nextUrl = navigation.url.href;
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
+
const isNoSpaNavigation = navigation.from && !navigation.to;
|
|
1006
|
+
// prevent redirect cycle on the same page,
|
|
1007
|
+
// except cases when we run no-spa navigations,
|
|
1008
|
+
// because we need hard reload in this cases
|
|
1009
|
+
if (isNoSpaNavigation ? true : prevUrl !== nextUrl) {
|
|
1005
1010
|
if (navigation.replace) {
|
|
1006
1011
|
window.location.replace(nextUrl);
|
|
1007
1012
|
}
|
package/lib/index.js
CHANGED
|
@@ -381,7 +381,9 @@ class AbstractRouter {
|
|
|
381
381
|
pathname = makePath(currentRoute.path, { ...currentRoute.params, ...params });
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
if (isSameHost(resultUrl)) {
|
|
385
|
+
pathname = this.normalizePathname(pathname);
|
|
386
|
+
}
|
|
385
387
|
return url.convertRawUrl(url.rawAssignUrl(resultUrl, {
|
|
386
388
|
pathname,
|
|
387
389
|
search: url$1 ? resultUrl.search : '',
|
|
@@ -1015,8 +1017,11 @@ class ClientRouter extends AbstractRouter {
|
|
|
1015
1017
|
// in case we didn't find any matched route just force hard page navigation
|
|
1016
1018
|
const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
|
|
1017
1019
|
const nextUrl = navigation.url.href;
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
+
const isNoSpaNavigation = navigation.from && !navigation.to;
|
|
1021
|
+
// prevent redirect cycle on the same page,
|
|
1022
|
+
// except cases when we run no-spa navigations,
|
|
1023
|
+
// because we need hard reload in this cases
|
|
1024
|
+
if (isNoSpaNavigation ? true : prevUrl !== nextUrl) {
|
|
1020
1025
|
if (navigation.replace) {
|
|
1021
1026
|
window.location.replace(nextUrl);
|
|
1022
1027
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import type { NavigateOptions, NavigationHook, NavigationSyncHook, NavigationGua
|
|
|
3
3
|
export declare const isFilePath: (pathname: string) => boolean;
|
|
4
4
|
export declare const normalizeTrailingSlash: (pathname: string, trailingSlash?: boolean) => string;
|
|
5
5
|
export declare const normalizeManySlashes: (hrefOrPath: string) => string;
|
|
6
|
-
export declare const isSameHost: import("@tinkoff/utils/typings/types").Func<true> | ((url: Url) => boolean);
|
|
6
|
+
export declare const isSameHost: import("@tinkoff/utils/typings/types").Func<true> | ((url: Url | URL) => boolean);
|
|
7
7
|
export declare const makeNavigateOptions: (options: string | NavigateOptions) => NavigateOptions;
|
|
8
8
|
export declare const registerHook: <T extends NavigationHook | NavigationSyncHook | NavigationGuard>(hooksSet: Set<T>, hook: T) => () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkoff/router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77",
|
|
4
4
|
"description": "router",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"build-for-publish": "true"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tinkoff/react-hooks": "0.0.
|
|
25
|
+
"@tinkoff/react-hooks": "0.0.26",
|
|
26
26
|
"@tinkoff/url": "0.7.38",
|
|
27
27
|
"@tinkoff/utils": "^2.1.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": ">=16.
|
|
30
|
+
"react": ">=16.14.0",
|
|
31
31
|
"tslib": "^2.0.3"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|