diff --git a/CHANGELOG.md b/CHANGELOG.md index 07b553e..b49527d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/projects/traversal/package.json b/projects/traversal/package.json index a9a3f64..053f5bc 100644 --- a/projects/traversal/package.json +++ b/projects/traversal/package.json @@ -1,6 +1,6 @@ { "name": "angular-traversal", - "version": "1.9.0", + "version": "1.9.1", "license": "MIT", "author": { "name": "Eric Brehault", diff --git a/projects/traversal/src/lib/traverser.directive.ts b/projects/traversal/src/lib/traverser.directive.ts index 9dece5e..edd39d8 100644 --- a/projects/traversal/src/lib/traverser.directive.ts +++ b/projects/traversal/src/lib/traverser.directive.ts @@ -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 }); } diff --git a/projects/traversal/src/lib/traverser.ts b/projects/traversal/src/lib/traverser.ts index 7f2eb0c..5dd088b 100644 --- a/projects/traversal/src/lib/traverser.ts +++ b/projects/traversal/src/lib/traverser.ts @@ -355,6 +355,6 @@ export class Traverser { } setPrefix(prefix: string) { - this.prefix.next(prefix); + this.prefix.next(prefix.startsWith('/') ? prefix : `/${prefix}`); } }