File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ export class FieldPath extends BasePath<FieldPath> {
265
265
canonicalString ( ) : string {
266
266
return this . toArray ( )
267
267
. map ( str => {
268
- str = str . replace ( '\\' , '\\\\' ) . replace ( '`' , '\\`' ) ;
268
+ str = str . replace ( / \\ / g , '\\\\' ) . replace ( / ` / g , '\\`' ) ;
269
269
if ( ! FieldPath . isValidIdentifier ( str ) ) {
270
270
str = '`' + str + '`' ;
271
271
}
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ export function mapCodeFromHttpStatus(status?: number): Code {
314
314
* Code.UNKNOWN.
315
315
*/
316
316
export function mapCodeFromHttpResponseErrorStatus ( status : string ) : Code {
317
- const serverError = status . toLowerCase ( ) . replace ( '_' , '-' ) ;
317
+ const serverError = status . toLowerCase ( ) . replace ( / _ / g , '-' ) ;
318
318
return Object . values ( Code ) . indexOf ( serverError as Code ) >= 0
319
319
? ( serverError as Code )
320
320
: Code . UNKNOWN ;
Original file line number Diff line number Diff line change @@ -160,6 +160,11 @@ describe('Path', () => {
160
160
expect ( abc . isPrefixOf ( ba ) ) . to . equal ( false ) ;
161
161
} ) ;
162
162
163
+ it ( 'escaped FieldPath with segments' , ( ) => {
164
+ const path = new FieldPath ( [ 'foo.`bar`' ] ) ;
165
+ expect ( path . canonicalString ( ) ) . to . equal ( '`foo.\\`bar\\``' ) ;
166
+ } ) ;
167
+
163
168
it ( 'can be constructed from field path.' , ( ) => {
164
169
const path = FieldPath . fromServerFormat ( 'foo\\..bar\\\\.baz' ) ;
165
170
expect ( path . toArray ( ) ) . to . deep . equal ( [ 'foo.' , 'bar\\' , 'baz' ] ) ;
You can’t perform that action at this time.
0 commit comments