• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

willmendesneto / ngx-feature-toggle / #1010

pending completion
#1010

push

snyk-bot
fix: upgrade zone.js from 0.11.5 to 0.12.0

Snyk has created this PR to upgrade zone.js from 0.11.5 to 0.12.0.

See this package in npm:
https://www.npmjs.com/package/zone.js

See this project in Snyk:
https://app.snyk.io/org/willmendesneto/project/486f5426-06e0-4cbf-8382-8b38e5a4e6a1?utm_source=github&utm_medium=referral&page=upgrade-pr

26 of 32 branches covered (81.25%)

Branch coverage included in aggregate %.

43 of 48 relevant lines covered (89.58%)

19.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/projects/ngx-feature-toggle/src/lib/ngx-feature-toggle-route-guard.router.ts
1
import { Injectable, isDevMode } from '@angular/core';
2
import {
3
  ActivatedRouteSnapshot,
4
  Route,
5
  CanActivateChild,
6
  Router,
7
  CanLoad,
8
  CanActivate,
9
} from '@angular/router';
10
import { isOn } from 'feature-toggle-service';
11

12
@Injectable({ providedIn: 'root' })
13
export class NgxFeatureToggleRouteGuard
1✔
14
  implements CanActivateChild, CanLoad, CanActivate {
15
  constructor(private router: Router) {}
27✔
16

17
  isDevMode() {
18
    return isDevMode();
6✔
19
  }
20

21
  private isOnCheck(route: ActivatedRouteSnapshot | Route): boolean {
22
    if (
30✔
23
      !route ||
114✔
24
      !route.data ||
25
      (typeof route.data.featureToggle !== 'string' &&
26
        !Array.isArray(route.data.featureToggle))
27
    ) {
28
      if (this.isDevMode()) {
12✔
29
        console.error(
6✔
30
          // tslint:disable-next-line: max-line-length
31
          '`NgxFeatureToggleRouteGuard` need to receive `featureToggle` as data as an array or string in your route configuration.'
32
        );
33
      }
34
      return false;
12✔
35
    }
36

37
    const hasAllTogglesOn = ([].concat(
18✔
38
      route.data.featureToggle
39
    ) as string[]).every((toggle) =>
40
      toggle[0] === '!' ? !isOn(toggle.replace('!', '')) : isOn(toggle)
21✔
41
    );
42

43
    if (!hasAllTogglesOn && route.data.redirectTo) {
18✔
44
      this.router.navigate([].concat(route.data.redirectTo));
3✔
45
    }
46

47
    return hasAllTogglesOn;
18✔
48
  }
49

50
  canLoad(route: Route): boolean {
51
    return this.isOnCheck(route);
10✔
52
  }
53

54
  canActivateChild(route: ActivatedRouteSnapshot | Route): boolean {
55
    return this.isOnCheck(route);
10✔
56
  }
57

58
  canActivate(route: ActivatedRouteSnapshot | Route): boolean {
59
    return this.isOnCheck(route);
10✔
60
  }
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc