File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import { isScoped, Scopable } from '../models';
29
29
/**
30
30
* Composes a valid JSON pointer with an arbitrary number of unencoded segments.
31
31
* This method encodes the segments to escape JSON pointer's special characters.
32
- * Empty segments (i.e. empty strings) are skipped.
32
+ * `undefined` segments are skipped.
33
33
*
34
34
* Example:
35
35
* ```ts
@@ -47,7 +47,7 @@ export const compose = (
47
47
pointer : string ,
48
48
...segments : ( string | number ) [ ]
49
49
) : string => {
50
- // Remove undefined segments and encode string segments. Number don't need encoding.
50
+ // Remove undefined segments and encode string segments. Numbers don't need encoding.
51
51
// Only skip undefined segments, as empty string segments are allowed
52
52
// and reference a property that has the empty string as property name.
53
53
const sanitizedSegments = segments
@@ -56,7 +56,7 @@ export const compose = (
56
56
57
57
return sanitizedSegments . reduce (
58
58
( currentPointer , segment ) => `${ currentPointer } /${ segment } ` ,
59
- pointer ?? ''
59
+ pointer ?? '' // Treat undefined and null the same as the empty string (root pointer)
60
60
) ;
61
61
} ;
62
62
You can’t perform that action at this time.
0 commit comments