Skip to content

Commit 3e04565

Browse files
committed
optimize: delete defaultUrlArgs variable, use * to match default urlArgs
1 parent 7792918 commit 3e04565

File tree

1 file changed

+8
-35
lines changed

1 file changed

+8
-35
lines changed

src/esl.js

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ var require;
10201020

10211021
if (newValue) {
10221022
if (key === 'urlArgs' && typeof newValue === 'string') {
1023-
defaultUrlArgs = newValue;
1023+
requireConf.urlArgs['*'] = newValue;
10241024
}
10251025
else {
10261026
// 简单的多处配置还是需要支持,所以配置实现为支持二级mix
@@ -1071,14 +1071,6 @@ var require;
10711071
*/
10721072
var mappingIdIndex;
10731073

1074-
/**
1075-
* 默认的urlArgs
1076-
*
1077-
* @inner
1078-
* @type {string}
1079-
*/
1080-
var defaultUrlArgs;
1081-
10821074
/**
10831075
* urlArgs内部索引
10841076
*
@@ -1152,7 +1144,7 @@ var require;
11521144
packagesIndex.sort(descSorterByKOrName);
11531145

11541146
// create urlArgs index
1155-
urlArgsIndex = createKVSortedIndex(requireConf.urlArgs);
1147+
urlArgsIndex = createKVSortedIndex(requireConf.urlArgs, 1);
11561148

11571149
// create noRequests index
11581150
noRequestsIndex = createKVSortedIndex(requireConf.noRequests);
@@ -1224,13 +1216,9 @@ var require;
12241216

12251217
// packages处理和匹配
12261218
if (!isPathMap) {
1227-
indexRetrieve(
1228-
id,
1229-
packagesIndex,
1230-
function (value, key, item) {
1231-
url = url.replace(item.name, item.location);
1232-
}
1233-
);
1219+
indexRetrieve(id, packagesIndex, function (value, key, item) {
1220+
url = url.replace(item.name, item.location);
1221+
});
12341222
}
12351223

12361224
// 相对路径时,附加baseUrl
@@ -1242,24 +1230,9 @@ var require;
12421230
url += extname + query;
12431231

12441232
// urlArgs处理和匹配
1245-
var isUrlArgsAppended;
12461233
indexRetrieve(id, urlArgsIndex, function (value) {
1247-
appendUrlArgs(value);
1234+
url += (url.indexOf('?') > 0 ? '&' : '?') + value;
12481235
});
1249-
defaultUrlArgs && appendUrlArgs(defaultUrlArgs);
1250-
1251-
/**
1252-
* 为url附加urlArgs
1253-
*
1254-
* @inner
1255-
* @param {string} args urlArgs串
1256-
*/
1257-
function appendUrlArgs(args) {
1258-
if (!isUrlArgsAppended) {
1259-
url += (url.indexOf('?') > 0 ? '&' : '?') + args;
1260-
isUrlArgsAppended = 1;
1261-
}
1262-
}
12631236

12641237
return url;
12651238
}
@@ -1282,15 +1255,15 @@ var require;
12821255

12831256
return requiredCache[ requireId ];
12841257
}
1285-
else if ( requireId instanceof Array ) {
1258+
else if (requireId instanceof Array) {
12861259
// 分析是否有resource,取出pluginModule先
12871260
var pluginModules = [];
12881261
var pureModules = [];
12891262
var normalizedIds = [];
12901263

12911264
each(
12921265
requireId,
1293-
function ( id, i ) {
1266+
function (id, i) {
12941267
var idInfo = parseId(id);
12951268
var absId = normalize(idInfo.module, baseId);
12961269
pureModules.push(absId);

0 commit comments

Comments
 (0)