
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
hand-node-seo
Advanced tools
It's a demo, do not use in production
npm install hand-node-seo --save
const RuleEngineClass = require('hand-node-seo').RuleEngineClass;
input: 1 if you have a html file, you can read it as string. The string could be an argument when create instance.
const htmlStr = fs.readFileSync('test/test.html').toString('utf-8');
const ruleEngine = new RuleEngineClass(htmlStr);
you don't need any callback function if you create instance this way, you can use the methods directly, for example: const ruleEngine = new RuleEngineClass(htmlStr) .addCustomRule(customRuleB) .runH1TagDetect() .runStrongTagDetect(1) .runTitleTagInHeadDetect() .addDetectMetaName('hands') .runMetaNameDetect() ...
2 Could be a ReadStream, there are two events 'readEnd','error' with property 'readStreamEvent' while your input is ReadStream. You will get an engine instance while readEnd happend, for example:
const ruleEngine = new RuleEngineClass();
ruleEngine.loadWithStream(request.get('https://www.google.com'));
or
ruleEngine.loadWithFile('test/test.html');
ruleEngine.readStreamEvent.on('readEnd', engine => {
engine
.....
});
ruleEngine.readStreamEvent.on('error', err => console.error(err));
As requirements, there are methods with the instance.
Detect if any tag without alt attribute
Detect if any tag without rel attribute
just use the 'runTagWithoutAttributeDetect(tagName, attrName)' for example: runTagWithoutAttributeDetect('img', 'alt')
In tag i. Detect if header doesn’t have tag
runTitleTagInHeadDetect()
ii. Detect if header doesn’t have <meta name=“descriptions” ... /> tag iii. Detect if header doesn’t have <meta name=“keywords” ... /> tag
runMetaNameDetect()
This method would detect attribute name with "description" and "keywords" as default, if you want to detect more names, just use addDetectMetaName(name) method before this method. for example:
ruleEngine
.addDetectMetaName('robots')
.runMetaNameDetect()
Detect if there’re more than 15 tag in HTML (15 is a value should be configurable by user)
runStrongTagDetect(maxLen)
default maxLen is 15
Detect if a HTML have more than one
runH1TagDetect()
Custom rules
The developer can make their own rules via addCustomRule(rule) method. The custom rules are formatted. For example:
const customRuleA = {
ruleName: 'customA',
execReg: function (html) {
const res = [];
if (!html || html.length === 0) {
res.push(`Custom A detect <h2>, 0 founded`);
return res;
}
let r = /<h2>/ig;
const arr = html.match(r);
if (!arr || arr.length === 0) {
res.push(`Custom A detect <h2>, 0 founded`);
return res;
}
res.push(`Custom A detect <h2>, ${arr.length} founded`);
return res;
}
};
1. The ruleName must be unique.
2. The function must return an array of string
And then, you can use method runCustomDetect() for running custom rules
ruleEngine
.addCustomRule(customRuleA)
.runCustomDetect()
Output can be:
A file, no returns, just save as a file toFile(filePath)
A writeStream, return a node writeStream object toFileStream(filePath, encoding)
console, no returns, just output to console
FAQs
seo package demo for
We found that hand-node-seo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.