Skip to content

Commit

Permalink
Merge pull request #525 from ozmar-11/enhancement/add-trailing-slash
Browse files Browse the repository at this point in the history
Validate if trailing slash is required
  • Loading branch information
neroniaky authored Jun 20, 2022
2 parents ea67b95 + c47266d commit 62ecc83
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions projects/angular-token/src/lib/angular-token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,21 @@ export class AngularTokenService implements CanActivate {
return (this.userType.value == null) ? '' : this.userType.value.path + '/';
}

private addTrailingSlashIfNeeded(url: string): string {
const lastChar = url[url.length - 1];

return lastChar === '/' ? url : url + '/';
}

private getApiPath(): string {
let constructedPath = '';

if (this.options.apiBase != null) {
constructedPath += this.options.apiBase + '/';
constructedPath += this.addTrailingSlashIfNeeded(this.options.apiBase);
}

if (this.options.apiPath != null) {
constructedPath += this.options.apiPath + '/';
constructedPath += this.addTrailingSlashIfNeeded(this.options.apiPath);
}

return constructedPath;
Expand Down

0 comments on commit 62ecc83

Please sign in to comment.