Match patterns

A match pattern is a URL with the following structure, used to specify a group of URLs:

<scheme>://<host>/<path>

scheme: Must be one of the following, separated from the rest of the pattern using a colon followed by a double slash (://):

  • http
  • https
  • A wildcard*, which matches onlyhttp orhttps
  • file

For information on injecting content scripts into unsupported schemes, such asabout: anddata:, seeInjecting in related frames.

host: A hostname (www.example.com). A* before the hostname to match subdomains (*.example.com), or just a wildcard*. - If you use a wildcard in the host pattern, it must be the first or only character, and it must be followed by a period (.) or forward slash (/).

path: A URL path (/example). For host permissions, the path is required but ignored. The wildcard (/*) should be used by convention.

Extensions use match patterns in a variety of use cases, including the following:

Special cases

"<all_urls>"
Matches any URL that starts with a permitted scheme, including any pattern listed undervalid patterns. Because it affects all hosts, Chrome web store reviews for extensions that use itmay take longer.
"file:///"
Allows your extension to run on local files. This pattern requires the user to manuallygrant access. Note that this case requires three slashes, not two.
Localhost URLs and IP addresses
To match any localhost port during development, usehttp://localhost/*. For IP addresses, specify the address plus a wildcard in the path, as inhttp://127.0.0.1/*. You can also usehttp://*:*/* to match localhost, IP addresses, and any port.
Top Level domain match patterns
Chrome doesn't support match patterns fortop Level domains (TLD). Specify your match patterns within individual TLDs, as inhttp://google.es/* andhttp://google.fr/*.

Example patterns

https://*/* orhttps://*/
Matches any URL using thehttps scheme.
https://*/foo*
Matches any URL using thehttps scheme, on any host, with a path that starts withfoo. Examples of matches includehttps://example.com/foo/bar.html andhttps://www.google.com/foo.
https://*.google.com/foo*bar
Matches any URL using thehttps scheme, on a google.com host, with a path that starts withfoo and ends withbar. Examples of matches includehttps://www.google.com/foo/baz/bar andhttps://docs.google.com/foobar.
file:///foo*
Matches any local file whose path starts withfoo. Examples of matches includefile:///foo/bar.html andfile:///foo.
http://127.0.0.1/* orhttp://127.0.0.1/
Matches any URL that uses thehttp scheme and is on the host 127.0.0.1. Examples of matches includehttp://127.0.0.1/ andhttp://127.0.0.1/foo/bar.html.
http://localhost/*
Matches any localhost port.
*://mail.google.com/ or*://mail.google.com/*
Matches any URL that starts withhttp://mail.google.com orhttps://mail.google.com.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2012-09-18 UTC.