fix(connections): accept empty rule extensions

This commit is contained in:
Tunglies
2026-11-15 22:38:16 +08:00
parent 99013ff982
commit 17ad32e7b5
+6 -2
View File
@@ -1,4 +1,4 @@
import { dump, load } from 'js-yaml'
import { dump, loadAll } from 'js-yaml'
import isFQDN from 'validator/es/lib/isFQDN'
import isIP from 'validator/es/lib/isIP'
@@ -65,7 +65,11 @@ export async function getConnectionRootDomain(host: string) {
}
function parseRuleExtension(content: string) {
const parsed: unknown = load(content)
const documents = loadAll(content)
if (documents.length > 1) {
throw new Error('The rule extension must contain a single YAML document.')
}
const parsed = documents[0]
if (
parsed !== undefined &&
parsed !== null &&