@@ -1069,50 +1069,30 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
10691069 // the null case preserves value as potentially relative
10701070 value = prependedResult ;
10711071 }
1072- } else if ( relativeTo . base && '@base' in activeCtx ) {
1072+ } else if ( relativeTo . base ) {
10731073 // prepend base
1074- if ( activeCtx [ '@base' ] ) {
1075- const prependedResult = prependBase (
1076- prependBase ( options . base , activeCtx [ '@base' ] ) , value ) ;
1077-
1078- let expansionMapResult = undefined ;
1079- if ( options && options . expansionMap ) {
1080- // if we are about to expand the value by prepending
1081- // @base then call the expansion map to inform
1082- // interested callers that this is occurring
1083-
1084- // TODO: use `await` to support async
1085- expansionMapResult = options . expansionMap ( {
1086- prependedIri : {
1087- type : '@base' ,
1088- base : activeCtx [ '@base' ] ,
1089- value,
1090- result : prependedResult
1091- } ,
1092- activeCtx,
1093- options
1094- } ) ;
1095- }
1096- if ( expansionMapResult !== undefined ) {
1097- value = expansionMapResult ;
1098- } else {
1099- // the null case preserves value as potentially relative
1100- value = prependedResult ;
1074+ let prependedResult ;
1075+ let expansionMapResult ;
1076+ let base ;
1077+ if ( '@base' in activeCtx ) {
1078+ if ( activeCtx [ '@base' ] ) {
1079+ base = prependBase ( options . base , activeCtx [ '@base' ] ) ;
1080+ prependedResult = prependBase ( base , value ) ;
11011081 }
1082+ } else {
1083+ base = options . base ;
1084+ prependedResult = prependBase ( options . base , value ) ;
11021085 }
1103- } else if ( relativeTo . base ) {
1104- const prependedResult = prependBase ( options . base , value ) ;
1105- let expansionMapResult = undefined ;
11061086 if ( options && options . expansionMap ) {
1107- // if we are about to expand the value by prepending
1087+ // if we are about to expand the value by pre-pending
11081088 // @base then call the expansion map to inform
11091089 // interested callers that this is occurring
11101090
11111091 // TODO: use `await` to support async
11121092 expansionMapResult = options . expansionMap ( {
11131093 prependedIri : {
11141094 type : '@base' ,
1115- base : options . base ,
1095+ base,
11161096 value,
11171097 result : prependedResult
11181098 } ,
@@ -1122,7 +1102,8 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
11221102 }
11231103 if ( expansionMapResult !== undefined ) {
11241104 value = expansionMapResult ;
1125- } else {
1105+ } else if ( prependedResult !== undefined ) {
1106+ // the null case preserves value as potentially relative
11261107 value = prependedResult ;
11271108 }
11281109 }
0 commit comments