GithubHelp home page GithubHelp logo

Comments (2)

cariboufute avatar cariboufute commented on May 28, 2024 1

I have the same problem and I have been able to fix it by making a quick fix in parseSegmentValue function in the localize-router.service.ts file.

The culprit is the condition else if (snapshot.routeConfig.data). When the route has a data key, snapshot.routeConfig.data returns both the object with the localizeRouter and the data key content.

To avoid this, I add a condition to check if there is a localizeRouter in the data (else if (snapshot.routeConfig.data && snapshot.routeConfig.data.localizeRouter)

Here is the whole method. Please check my fork for the fix : https://github.com/cariboufute/localize-router

// src/localize-router.service.ts
// ...

/**
   * Extracts new segment value based on routeConfig and url
   * @param snapshot
   * @returns {string}
   */
  private parseSegmentValue(snapshot: ActivatedRouteSnapshot): string {
    if (snapshot.routeConfig) {
      if (snapshot.routeConfig.path === '**') {
        return this.parser.translateRoute(snapshot.url
          .filter((segment: UrlSegment) => segment.path)
          .map((segment: UrlSegment) => segment.path)
          .join('/'));
      } else if (snapshot.routeConfig.data && snapshot.routeConfig.data.localizeRouter) {
        const subPathSegments = snapshot.routeConfig.data.localizeRouter.path.split('/');
        return subPathSegments
          .map((s: string, i: number) => s.indexOf(':') === 0 ?
            snapshot.url[i].path :
            this.parser.translateRoute(s))
          .join('/');
      }
    }
    return '';
  }

from localize-router.

Kateriine avatar Kateriine commented on May 28, 2024

Same issue here, I temporarily removed the data.

I just tested with data: { skipRouteLocalization: true }, it causes the same issue.

from localize-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.