3

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.

10
  • Does that accept regex? In my version (86.0.4240.111) it says "; use * for wildcard" which doesn't sound like it means the Kleene star. Commented May 12, 2021 at 11:24
  • It probably uses these patterns: developer.chrome.com/docs/extensions/match_patterns Commented May 12, 2021 at 11:28
  • Not able to find any solution yet :( Commented May 12, 2021 at 18:24
  • Do you wish to block it in the front-end or back-end? If you wish to block it in the back-end, which programming language are you working with? Java, Javascript, .NET, PHP? Commented May 13, 2021 at 10:43
  • In front end, from browser itself @justthink Commented May 13, 2021 at 16:28

1 Answer 1

2
+50

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.