Allow regex for path

This commit is contained in:
Fang-Pen Lin
2025-11-13 09:22:08 -08:00
parent 3b9c881586
commit 2f8700fdcd
5 changed files with 91 additions and 3 deletions
@@ -32,7 +32,18 @@ export const registerBddNockRouter = async (server: FastifyZodProvider) => {
const { body } = req;
const { definitions } = body;
logger.info(definitions, "Defining nock");
nock.define(definitions as Definition[]);
const processedDefinitions = definitions.map((definition: unknown) => {
const { path, ...rest } = definition as Definition;
return {
...rest,
path:
path !== undefined && typeof path === "string"
? path
: new RegExp((path as unknown as { regex: string }).regex ?? "")
} as Definition;
});
nock.define(processedDefinitions as Definition[]);
// Ensure we are activating the nocks, because we could have called `nock.restore()` before this call.
if (!nock.isActive()) {
nock.activate();
@@ -68,7 +68,9 @@ export const cloudflareDeleteTxtRecord = async (
},
params: {
type: "TXT",
name: domain,
// TODO: this is incorrect. The domain seems need to be fqdn, but we are passing just the record name here.
// as a result, we are not deleting the record correctly.
// name: domain,
content: value
}
});