Skip to content

Commit f81ce5f

Browse files
committed
fix(common): addLeadingSlash optional group support
1 parent 13290e9 commit f81ce5f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/common/test/utils/shared.utils.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ describe('Shared utils', () => {
117117
describe('addLeadingSlash', () => {
118118
it('should return the validated path ("add / if not exists")', () => {
119119
expect(addLeadingSlash('nope')).to.be.eql('/nope');
120+
expect(addLeadingSlash('{:nope}')).to.be.eql('/{:nope}');
120121
});
121122
it('should return the same path', () => {
122123
expect(addLeadingSlash('/nope')).to.be.eql('/nope');
124+
expect(addLeadingSlash('{/:nope}')).to.be.eql('{/:nope}');
123125
});
124126
it('should return empty path', () => {
125127
expect(addLeadingSlash('')).to.be.eql('');

packages/common/utils/shared.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const isPlainObject = (fn: any): fn is object => {
2525

2626
export const addLeadingSlash = (path?: string): string =>
2727
path && typeof path === 'string'
28-
? path.charAt(0) !== '/'
28+
? path.charAt(0) !== '/' && path.substring(0, 2) !== '{/'
2929
? '/' + path
3030
: path
3131
: '';

0 commit comments

Comments
 (0)