DEV Community

loading...
Cover image for Block specific URL using match pattern with Chrome

Block specific URL using match pattern with Chrome

abdelrahmanahmed profile image Wahdan ・1 min read

Today we are going to learn about blocking some URL with Chrome. There are many use cases to block a specific URL, one of them is that you need to test your application behavior when your images are not accessible anymore for any reason. Chrome has provided a built-in feature to do this, let's discover it.

The steps

1 - To access the DevTools, open a web page in Google Chrome and Right-click on any page and select Inspect.
2 - Click on three-dots icon ( at the top right of the DevTools).
3 - Navigate to more tools option.
4 - Click on the Request blocking option.
Alt Text
5- A new section is opened like the below image:
Alt Text
Click on Add pattern. This will show up a text field.
Alt Text
In the text field, you can write down any specific URL to block for example, https://www.websiteToBlock.com. Or you can use a pattern such as https://*.websiteToBlock.com/foo*, this will block any subdomain of websiteToBlock as long as the path starts with /foo and uses https schema. For more details about Match patterns, you can follow these references from Google Chrome and Mozilla.

Have a nice testing day.

Discussion

pic
Editor guide