Skip to content

Commit

Permalink
Merge pull request #46 from guillotinaweb/fix-prefix
Browse files Browse the repository at this point in the history
Fix traversed path when prefix is null
  • Loading branch information
ebrehault authored Sep 10, 2020
2 parents 00747e9 + 805825b commit 49cbd01
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.9.1 (2020-09-09)

## Bug fix
- Fix traversed path when prefix is null [ebrehault]

# 1.9.0 (2020-09-03)

## Improvement
Expand Down
2 changes: 1 addition & 1 deletion projects/traversal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-traversal",
"version": "1.9.0",
"version": "1.9.1",
"license": "MIT",
"author": {
"name": "Eric Brehault",
Expand Down
4 changes: 2 additions & 2 deletions projects/traversal/src/lib/traverser.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class TraverserOutlet implements OnInit, OnDestroy {

ngOnInit() {
this.traverser.target.pipe(takeUntil(this.terminator)).subscribe((target: Target) => this.render(target));
this.traverser.traverse(this.location.path().replace('/' + this.traverser.getPrefix(), ''), false);
this.traverser.traverse(this.location.path().replace(this.traverser.getPrefix(), ''), false);
this.location.subscribe((loc) => {
const path = (loc.url || '').replace('/' + this.traverser.getPrefix(), '');
const path = (loc.url || '').replace(this.traverser.getPrefix(), '');
this.traverser.traverse(path || '/', false); // when empty string traverse to root
});
}
Expand Down
2 changes: 1 addition & 1 deletion projects/traversal/src/lib/traverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,6 @@ export class Traverser {
}

setPrefix(prefix: string) {
this.prefix.next(prefix);
this.prefix.next(prefix.startsWith('/') ? prefix : `/${prefix}`);
}
}

0 comments on commit 49cbd01

Please sign in to comment.