@@ -1069,50 +1069,30 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
1069
1069
// the null case preserves value as potentially relative
1070
1070
value = prependedResult ;
1071
1071
}
1072
- } else if ( relativeTo . base && '@base' in activeCtx ) {
1072
+ } else if ( relativeTo . base ) {
1073
1073
// 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 ) ;
1101
1081
}
1082
+ } else {
1083
+ base = options . base ;
1084
+ prependedResult = prependBase ( options . base , value ) ;
1102
1085
}
1103
- } else if ( relativeTo . base ) {
1104
- const prependedResult = prependBase ( options . base , value ) ;
1105
- let expansionMapResult = undefined ;
1106
1086
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
1108
1088
// @base then call the expansion map to inform
1109
1089
// interested callers that this is occurring
1110
1090
1111
1091
// TODO: use `await` to support async
1112
1092
expansionMapResult = options . expansionMap ( {
1113
1093
prependedIri : {
1114
1094
type : '@base' ,
1115
- base : options . base ,
1095
+ base,
1116
1096
value,
1117
1097
result : prependedResult
1118
1098
} ,
@@ -1122,7 +1102,8 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
1122
1102
}
1123
1103
if ( expansionMapResult !== undefined ) {
1124
1104
value = expansionMapResult ;
1125
- } else {
1105
+ } else if ( prependedResult !== undefined ) {
1106
+ // the null case preserves value as potentially relative
1126
1107
value = prependedResult ;
1127
1108
}
1128
1109
}
0 commit comments