@tinkoff/router 0.1.64 → 0.1.65
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.es.js +4 -2
- package/lib/index.js +4 -2
- package/lib/router/abstract.d.ts +1 -0
- package/lib/router/server.d.ts +3 -6
- package/package.json +1 -1
package/lib/index.es.js
CHANGED
|
@@ -668,9 +668,11 @@ class RouteTree {
|
|
|
668
668
|
|
|
669
669
|
class Router extends AbstractRouter {
|
|
670
670
|
constructor(options) {
|
|
671
|
+
var _a;
|
|
671
672
|
super(options);
|
|
672
673
|
this.blocked = false;
|
|
673
674
|
this.tree = new RouteTree(options.routes);
|
|
675
|
+
this.defaultRedirectCode = (_a = options.defaultRedirectCode) !== null && _a !== void 0 ? _a : 308;
|
|
674
676
|
this.history = new ServerHistory();
|
|
675
677
|
}
|
|
676
678
|
async dehydrate() {
|
|
@@ -713,13 +715,13 @@ class Router extends AbstractRouter {
|
|
|
713
715
|
normalizePathname(pathname) {
|
|
714
716
|
const normalized = super.normalizePathname(pathname);
|
|
715
717
|
if (normalized !== pathname) {
|
|
716
|
-
this.redirectCode =
|
|
718
|
+
this.redirectCode = this.defaultRedirectCode;
|
|
717
719
|
}
|
|
718
720
|
return normalized;
|
|
719
721
|
}
|
|
720
722
|
resolveUrl(options) {
|
|
721
723
|
if (options.url && isInvalidUrl(options.url)) {
|
|
722
|
-
this.redirectCode =
|
|
724
|
+
this.redirectCode = this.defaultRedirectCode;
|
|
723
725
|
}
|
|
724
726
|
return super.resolveUrl(options);
|
|
725
727
|
}
|
package/lib/index.js
CHANGED
|
@@ -684,9 +684,11 @@ class RouteTree {
|
|
|
684
684
|
|
|
685
685
|
class Router extends AbstractRouter {
|
|
686
686
|
constructor(options) {
|
|
687
|
+
var _a;
|
|
687
688
|
super(options);
|
|
688
689
|
this.blocked = false;
|
|
689
690
|
this.tree = new RouteTree(options.routes);
|
|
691
|
+
this.defaultRedirectCode = (_a = options.defaultRedirectCode) !== null && _a !== void 0 ? _a : 308;
|
|
690
692
|
this.history = new ServerHistory();
|
|
691
693
|
}
|
|
692
694
|
async dehydrate() {
|
|
@@ -729,13 +731,13 @@ class Router extends AbstractRouter {
|
|
|
729
731
|
normalizePathname(pathname) {
|
|
730
732
|
const normalized = super.normalizePathname(pathname);
|
|
731
733
|
if (normalized !== pathname) {
|
|
732
|
-
this.redirectCode =
|
|
734
|
+
this.redirectCode = this.defaultRedirectCode;
|
|
733
735
|
}
|
|
734
736
|
return normalized;
|
|
735
737
|
}
|
|
736
738
|
resolveUrl(options) {
|
|
737
739
|
if (options.url && url.isInvalidUrl(options.url)) {
|
|
738
|
-
this.redirectCode =
|
|
740
|
+
this.redirectCode = this.defaultRedirectCode;
|
|
739
741
|
}
|
|
740
742
|
return super.resolveUrl(options);
|
|
741
743
|
}
|
package/lib/router/abstract.d.ts
CHANGED
package/lib/router/server.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { Options } from './abstract';
|
|
2
2
|
import { AbstractRouter } from './abstract';
|
|
3
|
-
import type { Navigation, NavigateOptions, HookName
|
|
3
|
+
import type { Navigation, NavigateOptions, HookName } from '../types';
|
|
4
4
|
export declare class Router extends AbstractRouter {
|
|
5
|
+
protected defaultRedirectCode: number;
|
|
5
6
|
protected blocked: boolean;
|
|
6
7
|
protected redirectCode?: number;
|
|
7
|
-
constructor(options: Options
|
|
8
|
-
onRedirect: (navigation: Navigation) => Promise<void>;
|
|
9
|
-
onNotFound: NavigationHook;
|
|
10
|
-
onBlock: NavigationHook;
|
|
11
|
-
});
|
|
8
|
+
constructor(options: Options);
|
|
12
9
|
protected onRedirect: (navigation: Navigation) => Promise<void>;
|
|
13
10
|
dehydrate(): Promise<Navigation>;
|
|
14
11
|
protected run(navigation: Navigation): Promise<void>;
|