Skip to content

Commit cac1b4b

Browse files
nleushiparamonau
andauthored
Allow disable htmlparser plugin (#643)
* allow disable htmlparser plugin * rename `allow-htmlparser.js` to `__allowHtmlparser.js` * fix filename typo * allow override by imported plugins --------- Co-authored-by: Ivan Paramonau <i.paramonau@gmail.com>
1 parent 39f63d1 commit cac1b4b

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

lib/loader/pluginLoader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@
283283
// ID.
284284
pluginDeclaration.id = getFileName(bits[bits.length - 1]).toLowerCase();
285285
if (pluginDeclaration.id in plugins) {
286-
if (CONFIG.CUSTOM_PLUGINS_PATH && pluginPath.indexOf(CONFIG.CUSTOM_PLUGINS_PATH) > -1) {
286+
if (pluginPath.indexOf('node_modules') > -1
287+
|| (CONFIG.CUSTOM_PLUGINS_PATH && pluginPath.indexOf(CONFIG.CUSTOM_PLUGINS_PATH) > -1)) {
287288
console.error("Plugin '" + pluginDeclaration.id + "' overridden by", pluginPath);
288289
delete plugins[pluginDeclaration.id]
289290
} else {
290-
console.error("Duplicate plugin id (filename)", pluginPath);
291+
console.error("Duplicate plugin id ignored (filename)", pluginPath);
291292
return;
292293
}
293294
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
export default {
3+
4+
provides: [
5+
// Run for all who requests htmlparser or meta.
6+
'htmlparser',
7+
'__allowHtmlparser'
8+
],
9+
10+
getData: function() {
11+
return {
12+
__allowHtmlparser: true
13+
};
14+
}
15+
};

lib/plugins/system/htmlparser/htmlparser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default {
1616
'__statusCode'
1717
],
1818

19-
getData: function(url, whitelistRecord, options, __noCachedHtmlparserFallback, cb) {
19+
getData: function(url, whitelistRecord, options, __noCachedHtmlparserFallback, __allowHtmlparser, cb) {
2020

2121
var options2 = {...options, ...{
2222
followRedirect: !!options.followHTTPRedirect,

0 commit comments

Comments
 (0)