SukkaW d354c5e988
Some checks are pending
Build / Build (push) Waiting to run
Build / Diff output (push) Blocked by required conditions
Build / Deploy to Cloudflare Pages (push) Blocked by required conditions
Build / Deploy to GitHub and GitLab (push) Blocked by required conditions
Chore: maintainance
2025-02-07 17:52:36 +08:00

63 lines
2.1 KiB
JavaScript

'use strict';Object.defineProperty(exports,Symbol.toStringTag,{value:'Module'});const base=require('../../../_virtual/base2.cjs'),createFile=require('../create-file.cjs');var hasRequiredBase;
function requireBase () {
if (hasRequiredBase) return base.__exports;
hasRequiredBase = 1;
(function (exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "BaseWriteStrategy", {
enumerable: true,
get: function() {
return BaseWriteStrategy;
}
});
const _createfile = /*@__PURE__*/ createFile.__require();
class BaseWriteStrategy {
outputDir;
/**
* Sometimes a ruleset will create extra files (e.g. reject-url-regex w/ mitm.sgmodule),
* and doesn't share the same filename and id. This property is used to overwrite the filename.
*/ overwriteFilename;
withFilename(filename) {
this.overwriteFilename = filename;
return this;
}
constructor(outputDir){
this.outputDir = outputDir;
this.overwriteFilename = null;
}
static domainWildCardToRegex = (domain)=>{
let result = '^';
for(let i = 0, len = domain.length; i < len; i++){
switch(domain[i]){
case '.':
result += String.raw`\.`;
break;
case '*':
result += String.raw`[\w.-]*?`;
break;
case '?':
result += String.raw`[\w.-]`;
break;
default:
result += domain[i];
}
}
result += '$';
return result;
};
output(span, title, description, date, filePath) {
if (!this.result) {
return;
}
return (0, _createfile.compareAndWriteFile)(span, this.withPadding(title, description, date, this.result), filePath);
}
get content() {
return this.result;
}
}
} (base.__exports));
return base.__exports;
}exports.__require=requireBase;