@@ -1055,8 +1055,8 @@ async function _retrieveContextUrls(input, options) {
1055
1055
*/
1056
1056
function _findContextUrls ( input , urls , replace , base ) {
1057
1057
if ( _isArray ( input ) ) {
1058
- for ( let i = 0 ; i < input . length ; ++ i ) {
1059
- _findContextUrls ( input [ i ] , urls , replace , base ) ;
1058
+ for ( const element of input ) {
1059
+ _findContextUrls ( element , urls , replace , base ) ;
1060
1060
}
1061
1061
return ;
1062
1062
}
@@ -1074,31 +1074,29 @@ function _findContextUrls(input, urls, replace, base) {
1074
1074
}
1075
1075
1076
1076
// get @context
1077
- let ctx = input [ key ] ;
1077
+ const ctx = input [ key ] ;
1078
1078
1079
1079
if ( _isArray ( ctx ) ) {
1080
1080
// array @context
1081
1081
let length = ctx . length ;
1082
1082
for ( let i = 0 ; i < length ; ++ i ) {
1083
- let _ctx = ctx [ i ] ;
1083
+ const _ctx = ctx [ i ] ;
1084
1084
if ( _isString ( _ctx ) ) {
1085
- _ctx = prependBase ( base , _ctx ) ;
1085
+ const prepended = prependBase ( base , _ctx ) ;
1086
+ const resolved = urls [ prepended ] ;
1086
1087
// replace w/@context if requested
1087
1088
if ( replace ) {
1088
- if ( urls [ _ctx ] !== false ) {
1089
- _ctx = urls [ _ctx ] ;
1090
- if ( _isArray ( _ctx ) ) {
1091
- // add flattened context
1092
- Array . prototype . splice . apply ( ctx , [ i , 1 ] . concat ( _ctx ) ) ;
1093
- i += _ctx . length - 1 ;
1094
- length = ctx . length ;
1095
- } else {
1096
- ctx [ i ] = _ctx ;
1097
- }
1089
+ if ( _isArray ( resolved ) ) {
1090
+ // add flattened context
1091
+ Array . prototype . splice . apply ( ctx , [ i , 1 ] . concat ( resolved ) ) ;
1092
+ i += resolved . length - 1 ;
1093
+ length = ctx . length ;
1094
+ } else {
1095
+ ctx [ i ] = resolved ;
1098
1096
}
1099
- } else if ( ! ( _ctx in urls ) ) {
1097
+ } else if ( resolved === undefined ) {
1100
1098
// @context URL found
1101
- urls [ _ctx ] = false ;
1099
+ urls [ prepended ] = false ;
1102
1100
}
1103
1101
} else {
1104
1102
// look for scoped context
@@ -1111,15 +1109,16 @@ function _findContextUrls(input, urls, replace, base) {
1111
1109
}
1112
1110
} else if ( _isString ( ctx ) ) {
1113
1111
// string @context
1114
- ctx = prependBase ( base , ctx ) ;
1112
+ const prepended = prependBase ( base , ctx ) ;
1113
+ const resolved = urls [ prepended ] ;
1115
1114
// replace w/@context if requested
1116
1115
if ( replace ) {
1117
- if ( urls [ ctx ] !== false ) {
1118
- input [ key ] = urls [ ctx ] ;
1116
+ if ( resolved !== false ) {
1117
+ input [ key ] = resolved ;
1119
1118
}
1120
- } else if ( ! ( ctx in urls ) ) {
1119
+ } else if ( resolved === undefined ) {
1121
1120
// @context URL found
1122
- urls [ ctx ] = false ;
1121
+ urls [ prepended ] = false ;
1123
1122
}
1124
1123
} else {
1125
1124
// look for scoped context
0 commit comments