11explorer = {
22 shortenEntity : function ( entity ) {
33 if ( entity ) {
4+ if ( entity [ 0 ] === "(" ) {
5+ let pair = this . parsePair ( entity ) ;
6+ return "(" + this . shortenEntity ( pair [ 0 ] ) + ", " + pair [ 1 ] + ")" ;
7+ }
8+
49 let escaped = entity . replaceAll ( "\\." , "@@" ) ;
510 escaped = escaped . split ( "." ) . pop ( ) ;
611 escaped = escaped . replaceAll ( "@@" , "." ) ;
712 return escaped ;
813 }
914 } ,
1015
16+ parsePair : function ( expr ) {
17+ if ( expr [ 0 ] !== "(" ) {
18+ console . error ( "Invalid pair: " + expr ) ;
19+ return undefined ;
20+ }
21+
22+ return expr . slice ( 1 , - 1 ) . split ( "," ) ;
23+ } ,
24+
1125 shortenComponent : function ( component ) {
1226 let result ;
1327 if ( component [ 0 ] !== "(" ) {
1428 // Not a pair
1529 result = this . shortenEntity ( component ) ;
1630 } else {
17- let pair = component . slice ( 1 , - 1 ) . split ( "," ) ;
31+ let pair = this . parsePair ( component ) ;
1832 let rel = this . shortenEntity ( pair [ 0 ] ) ;
1933 result = "(" + this . shortenEntity ( pair [ 0 ] ) + ", " + pair [ 1 ] + ")" ;
2034 }
@@ -23,6 +37,9 @@ explorer = {
2337
2438 entityParent : function ( path ) {
2539 path = path . replaceAll ( "\\\." , "@@" ) ;
40+ if ( path [ 0 ] === "(" ) {
41+ path = this . parsePair ( path ) [ 0 ] ;
42+ }
2643 const names = path . split ( "." ) ;
2744 names . pop ( ) ;
2845 return names . join ( "." ) . replaceAll ( "@@" , "." ) ;
0 commit comments