fix(core): update

This commit is contained in:
2021-01-03 03:41:46 +00:00
commit 2a8285bd0c
13 changed files with 11503 additions and 0 deletions

24
ts/index.ts Normal file
View File

@ -0,0 +1,24 @@
import * as plugins from './smartrobots.plugins';
export class Smartrobots {
private webrequestInstance = new plugins.webrequest.WebRequest();
public async parseRobotsTxtFromUrl(urlArg: string) {
const robotsTxtString = await (
await this.webrequestInstance.request(urlArg, {
method: 'GET',
})
).text();
const parsedResult = this.parseRobotsTxt(robotsTxtString);
return parsedResult;
}
public async parseRobotsTxt(robotsTxt: string) {
const lineArray = robotsTxt.split('\n');
return {
sitemaps: lineArray
.filter((lineArg) => lineArg.startsWith('Sitemap: '))
.map((lineArg) => lineArg.replace('Sitemap: ', '')),
};
}
}

View File

@ -0,0 +1,6 @@
// @pushrocks scope
import * as webrequest from '@pushrocks/webrequest';
export {
webrequest
}