I'm intercepting a request with Cypress and I'm trying not to hardcode something. To make it work correctly, I have to add a "1" since I'm trying to intercept something like this:
/api/v1/contacts/cfs:12345/forms/144543
The problem is that there are other requests like /forms/something that are being intercepted if I use forms/**, leading to this:
let urlResponse = '/api/v1/contacts/cfs:' + $code + '/forms/1**'
Is there any regex or something that could let me just intercept the URL that's forms/number and not forms/something or forms/number/something?
Here is some regex for matching just the .../forms/number pattern.
const inputs = [
'/api/v1/contacts/cfs:12345/forms/144543',
'/api/v1/contacts/cfs:12345/forms/something',
'/api/v1/contacts/cfs:12345/forms/144543/something'
];
const regex = new RegExp('/api/v1/contacts/cfs:12345/forms/[0-9]+$');
for (let input of inputs) {
const isMatch = regex.test(input);
console.log(isMatch);
}