Block Specific Request URL in chrome, but URL with sub-directory should pass

Viewed 684

I am trying to block specific request URL like this - https://somedomain.co.in/api/consultation

by using "Block Request URL" in Google Chrome Network tab.

But the issue I am facing is that the Block request URL is blocking all URL starting with the above pattern, like it is blocking -

https://somedomain.co.in/api/consultation/subdirectory

I want to block only - https://somedomain.co.in/api/consultation

I tried Changing the text pattern in "Network request blocking" tab, but no luck.

Did anyone face a similar situation?

Note - I don't want to use any extra script, there should be some way with chrome itself or Mozilla or maybe upcoming update in chrome.

1 Answers

Looking at the source code of the Developer tools I can conclude there is no way to do that.

/**
 * @param {string} pattern
 * @param {string} url
 * @return {boolean}
 */
_matches(pattern, url) {
    var pos = 0;
    var parts = pattern.split('*');
    for (var index = 0; index < parts.length; index++) {
      var part = parts[index];
      if (!part.length)
        continue;
      pos = url.indexOf(part, pos);
      if (pos === -1)
        return false;
      pos += part.length;
    }
    return true;
}

It only supports wildcards using asterisks. No matter what you want to ignore with your given URL, it will always match.

There is no support for RegEx either, until something like that will be added, it will be possible.

And no, this won't be added anytime soon, unless someone adds this feature and submits a pull request.

https://github.com/ChromeDevTools/devtools-frontend

Related