Skip to content

Commit 92b4c55

Browse files
authored
Merge pull request #11226 from marmelab/fix-escape-path-escaping
Escape backslashes in escapePath
2 parents e8417d9 + a508374 commit 92b4c55

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import expect from 'expect';
2+
3+
import escapePath from './escapePath';
4+
5+
describe('escapePath', () => {
6+
it('escapes parentheses', () => {
7+
expect(escapePath('/foo(bar)')).toEqual('/foo\\(bar\\)');
8+
});
9+
10+
it('escapes backslashes before escaping parentheses', () => {
11+
expect(escapePath('/foo\\(bar)')).toEqual('/foo\\\\\\(bar\\)');
12+
});
13+
});

packages/ra-core/src/util/escapePath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
*
88
* escapePath('/foo(bar)') => 'foo\(bar\)'
99
*/
10-
export default url => url.replace(/(\(|\))/g, '\\$1');
10+
export default url => url.replace(/\\/g, '\\\\').replace(/[()]/g, '\\$&');

0 commit comments

Comments
 (0)