@tinkoff/router 0.1.72 → 0.1.73

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.
@@ -765,13 +765,19 @@ class ClientRouter extends AbstractRouter {
765
765
  return super.resolveRoute(...options);
766
766
  }
767
767
  async notfound(navigation) {
768
+ var _a, _b;
768
769
  await super.notfound(navigation);
769
770
  // in case we didn't find any matched route just force hard page navigation
770
- if (navigation.replace) {
771
- window.location.replace(navigation.url.href);
772
- }
773
- else {
774
- window.location.assign(navigation.url.href);
771
+ const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
772
+ const nextUrl = navigation.url.href;
773
+ // prevent redirect cycle on the same page
774
+ if (prevUrl !== nextUrl) {
775
+ if (navigation.replace) {
776
+ window.location.replace(nextUrl);
777
+ }
778
+ else {
779
+ window.location.assign(nextUrl);
780
+ }
775
781
  }
776
782
  // prevent routing from any continues navigation returning promise which will be not resolved
777
783
  return new Promise(() => { });
package/lib/index.es.js CHANGED
@@ -995,13 +995,19 @@ class ClientRouter extends AbstractRouter {
995
995
  return super.resolveRoute(...options);
996
996
  }
997
997
  async notfound(navigation) {
998
+ var _a, _b;
998
999
  await super.notfound(navigation);
999
1000
  // in case we didn't find any matched route just force hard page navigation
1000
- if (navigation.replace) {
1001
- window.location.replace(navigation.url.href);
1002
- }
1003
- else {
1004
- window.location.assign(navigation.url.href);
1001
+ const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
1002
+ const nextUrl = navigation.url.href;
1003
+ // prevent redirect cycle on the same page
1004
+ if (prevUrl !== nextUrl) {
1005
+ if (navigation.replace) {
1006
+ window.location.replace(nextUrl);
1007
+ }
1008
+ else {
1009
+ window.location.assign(nextUrl);
1010
+ }
1005
1011
  }
1006
1012
  // prevent routing from any continues navigation returning promise which will be not resolved
1007
1013
  return new Promise(() => { });
package/lib/index.js CHANGED
@@ -1010,13 +1010,19 @@ class ClientRouter extends AbstractRouter {
1010
1010
  return super.resolveRoute(...options);
1011
1011
  }
1012
1012
  async notfound(navigation) {
1013
+ var _a, _b;
1013
1014
  await super.notfound(navigation);
1014
1015
  // in case we didn't find any matched route just force hard page navigation
1015
- if (navigation.replace) {
1016
- window.location.replace(navigation.url.href);
1017
- }
1018
- else {
1019
- window.location.assign(navigation.url.href);
1016
+ const prevUrl = (_b = (_a = navigation.fromUrl) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : window.location.href;
1017
+ const nextUrl = navigation.url.href;
1018
+ // prevent redirect cycle on the same page
1019
+ if (prevUrl !== nextUrl) {
1020
+ if (navigation.replace) {
1021
+ window.location.replace(nextUrl);
1022
+ }
1023
+ else {
1024
+ window.location.assign(nextUrl);
1025
+ }
1020
1026
  }
1021
1027
  // prevent routing from any continues navigation returning promise which will be not resolved
1022
1028
  return new Promise(() => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkoff/router",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "description": "router",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",