Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/common/extensions/docs/server2/templates/articles/match_patterns.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: script/build.py fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <h1 class="page_title">Match Patterns</h1>
2 <p>
3 <a href="content_scripts.html">Content scripts</a> operate on
4 a set of URLs defined by match patterns.
5 You can put one or more match patterns
6 in the <code>"matches"</code> part of
7 a content script's section of the manifest,
8 as well as in the <code>"exclude_matches"</code> section.
9 This page describes the match pattern syntax &mdash;
10 the rules you need to follow when you specify
11 which URLs your content script affects.
12 </p>
13 <p>
14 A match pattern is essentially a URL
15 that begins with a permitted scheme (<code>http</code>,
16 <code>https</code>, <code>file</code>, <code>ftp</code>, or
17 <code>chrome-extension</code>),
18 and that can contain '<code>*</code>' characters.
19 The special pattern
20 <code>&lt;all_urls&gt;</code> matches any URL
21 that starts with a permitted scheme.
22 Each match pattern has 3 parts:</p>
23 </p>
24 <ul>
25 <li> <em>scheme</em> &mdash;
26 for example, <code>http</code> or <code>file</code>
27 or <code>*</code>
28 <p class="note">
29 <b>Note:</b>
30 Access to <code>file</code> URLs isn't automatic.
31 The user must visit the extensions management page
32 and opt in to <code>file</code> access for each extension that requests it.
33 </p>
34 </li>
35 <li> <em>host</em> &mdash;
36 for example, <code>www.google.com</code>
37 or <code>*.google.com</code>
38 or <code>*</code>;
39 if the scheme is <code>file</code>,
40 there is no <em>host</em> part
41 </li>
42 <li> <em>path</em> &mdash;
43 for example, <code>/*</code>, <code>/foo* </code>,
44 or <code>/foo/bar </code>
45 </li>
46 </ul>
47 <p>Here's the basic syntax:</p>
48 <pre>
49 <em>&lt;url-pattern&gt;</em> := <em>&lt;scheme&gt;</em>://<em>&lt;host&gt;</em>< em>&lt;path&gt;</em>
50 <em>&lt;scheme&gt;</em> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome-ext ension'
51 <em>&lt;host&gt;</em> := '*' | '*.' <em>&lt;any char except '/' and '*'&gt;</em> +
52 <em>&lt;path&gt;</em> := '/' <em>&lt;any chars&gt;</em>
53 </pre>
54 <p>
55 The meaning of '<code>*</code>' depends on whether
56 it's in the <em>scheme</em>, <em>host</em>, or <em>path</em> part.
57 If the <em>scheme</em> is <code>*</code>,
58 then it matches either <code>http</code> or <code>https</code>.
59 If the <em>host</em> is just <code>*</code>,
60 then it matches any host.
61 If the <em>host</em> is <code>*.<em>hostname</em></code>,
62 then it matches the specified host or any of its subdomains.
63 In the <em>path</em> section,
64 each '<code>*</code>' matches 0 or more characters.
65 The following table shows some valid patterns.
66 </p>
67 <table class="columns">
68 <tbody>
69 <tr>
70 <th style="margin-left:0; padding-left:0">Pattern</th>
71 <th style="margin-left:0; padding-left:0">What it does</th>
72 <th style="margin-left:0; padding-left:0">Examples of matching URLs</th>
73 </tr>
74 <tr>
75 <td>
76 <code>http://*/*</code>
77 </td>
78 <td>Matches any URL that uses the <code>http</code> scheme</td>
79 <td>
80 http://www.google.com/<br>
81 http://example.org/foo/bar.html
82 </td>
83 </tr>
84 <tr>
85 <td>
86 <code>http://*/foo*</code>
87 </td>
88 <td>
89 Matches any URL that uses the <code>http</code> scheme, on any host,
90 as long as the path starts with <code>/foo</code>
91 </td>
92 <td>
93 http://example.com/foo/bar.html<br>
94 http://www.google.com/foo<b></b>
95 </td>
96 </tr>
97 <tr>
98 <td>
99 <code>https://*.google.com/foo*bar </code>
100 </td>
101 <td>
102 Matches any URL that uses the <code>https</code> scheme,
103 is on a google.com host
104 (such as www.google.com, docs.google.com, or google.com),
105 as long as the path starts with <code>/foo</code>
106 and ends with <code>bar</code>
107 </td>
108 <td>
109 http://www.google.com/foo/baz/bar<br>
110 http://docs.google.com/foobar
111 </td>
112 </tr>
113 <tr>
114 <td>
115 <code>http://example.org/foo/bar.html </code>
116 </td>
117 <td>Matches the specified URL</td>
118 <td>
119 http://example.org/foo/bar.html
120 </td>
121 </tr>
122 <tr>
123 <td>
124 <code>file:///foo*</code>
125 </td>
126 <td>Matches any local file whose path starts with <code>/foo</code>
127 </td>
128 <td>
129 file:///foo/bar.html<br>
130 file:///foo
131 </td>
132 </tr>
133 <tr>
134 <td>
135 <code>http://127.0.0.1/*</code>
136 </td>
137 <td>
138 Matches any URL that uses the <code>http</code> scheme
139 and is on the host 127.0.0.1
140 </td>
141 <td>
142 http://127.0.0.1/<br>
143 http://127.0.0.1/foo/bar.html
144 </td>
145 </tr>
146 <tr>
147 <td>
148 <code>*://mail.google.com/* </code>
149 </td>
150 <td>
151 Matches any URL that starts with
152 <code>http://mail.google.com</code> or
153 <code>https://mail.google.com</code>.
154 </td>
155 <td>
156 http://mail.google.com/foo/baz/bar<br>
157 https://mail.google.com/foobar
158 </td>
159 </tr>
160 <tr>
161 <td>
162 <code>chrome-extension://*/* </code>
163 </td>
164 <td>
165 Matches any URL pointing to an extension (the first <code>*</code>
166 represents a filter for extension IDs, the second for paths).
167 </td>
168 <td>
169 chrome-extension://askla...asdf/options.html
170 </td>
171 </tr>
172 <tr>
173 <td>
174 <code>&lt;all_urls&gt;</code>
175 </td>
176 <td>
177 Matches any URL that uses a permitted scheme.
178 (See the beginning of this section for the list of permitted
179 schemes.)
180 </td>
181 <td>
182 http://example.org/foo/bar.html<br>
183 file:///bar/baz.html
184 </td>
185 </tr>
186 </tbody>
187 </table>
188 <p>
189 Here are some examples of <em>invalid</em> pattern matches:
190 </p>
191 <table class="columns">
192 <tbody>
193 <tr>
194 <th style="margin-left:0; padding-left:0">Bad pattern</th>
195 <th style="margin-left:0; padding-left:0">Why it's bad</th>
196 </tr>
197 <tr>
198 <td><code>http://www.google.com</code></td>
199 <td>No <em>path</em></td>
200 </tr>
201 <tr>
202 <td><code>http://*foo/bar</code></td>
203 <td>'*' in the <em>host</em> can be followed only by a '.' or '/'</td>
204 </tr>
205 <tr>
206 <td><code>http://foo.*.bar/baz&nbsp; </code></td>
207 <td>If '*' is in the <em>host</em>, it must be the first character</td>
208 </tr>
209 <tr>
210 <td><code>http:/bar</code></td>
211 <td>Missing <em>scheme</em> separator ("/" should be "//")</td>
212 </tr>
213 <tr>
214 <td><code>foo://*</code></td>
215 <td>Invalid <em>scheme</em></td>
216 </tr>
217 </tbody>
218 </table>
219 <p>
220 Some schemes are not supported in all contexts.
221 </p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698