clove/isATracker
src/lib/server/rules/cnameUrl.ts
/* src/lib/server/rules/cnameUrl.ts
* MIT — (c) Doughmination System®
*/
import { httpUrlPrefix, readRecordTarget } from './recordTargets.ts';
import type { Rule, Violation } from './types.ts';
import { findCnameLine } from './unsupportedCname.ts';
export const cnameUrlRule: Rule = {
id: 'cnameUrl',
title: 'HTTP or HTTPS URL in CNAME',
severity: 2,
actionType: 'requestChanges',
actionLabel: 'Request Changes',
findLine: (file) => findCnameLine(file.content),
async evaluate(context) {
const violations: Violation[] = [];
for (const file of context.files) {
const target = readRecordTarget(file.json, 'CNAME');
if (target !== null && httpUrlPrefix.test(target)) {
violations.push({
ruleId: 'cnameUrl',
filePath: file.path,
reason: 'CNAME contains an HTTP or HTTPS URL. Use a hostname.'
});
}
}
return violations;
}
};