website-scraper
Version:
Download website to a local directory (including all css, images, js, etc.)
30 lines (23 loc) • 618 B
JavaScript
import {isUriSchemaSupported} from '../../utils/index.js';
function getPaths (text) {
const isSamePageId = text.startsWith('#');
const uriSchemaSupported = isUriSchemaSupported(text);
if (isSamePageId || !uriSchemaSupported) {
return [];
}
return [text];
}
class HtmlCommonTag {
constructor (text) {
this.text = text || '';
this.paths = getPaths(this.text);
}
getPaths () {
return this.paths;
}
updateText (pathsToUpdate) {
const pathToUpdate = pathsToUpdate.find(p => p.oldPath === this.paths[0]);
return pathToUpdate ? pathToUpdate.newPath : this.text;
}
}
export default HtmlCommonTag;