File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 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';
2929/**
3030 * Composes a valid JSON pointer with an arbitrary number of unencoded segments.
3131 * 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.
3333 *
3434 * Example:
3535 * ```ts
@@ -47,7 +47,7 @@ export const compose = (
4747 pointer : string ,
4848 ...segments : ( string | number ) [ ]
4949) : 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.
5151 // Only skip undefined segments, as empty string segments are allowed
5252 // and reference a property that has the empty string as property name.
5353 const sanitizedSegments = segments
@@ -56,7 +56,7 @@ export const compose = (
5656
5757 return sanitizedSegments . reduce (
5858 ( currentPointer , segment ) => `${ currentPointer } /${ segment } ` ,
59- pointer ?? ''
59+ pointer ?? '' // Treat undefined and null the same as the empty string (root pointer)
6060 ) ;
6161} ;
6262
You can’t perform that action at this time.
0 commit comments