Match patterns أنماط المطابقة
Match patterns are a way to specify groups of URLs: a match pattern matches a specific set of URLs. They are used in WebExtensions APIs in a few places, most notably to specify which documents to load content scripts into, and to specify which URLs to add webRequest
listeners to.
أنماط المطابقة هي طريقة لتحديد مجموعات من عناوين URL: يتطابق نمط المطابقة مع مجموعة محددة من عناوين URL. يتم استخدامها في واجهات برمجة تطبيقات WebExtensions في أماكن قليلة ، وعلى الأخص لتحديد المستندات التي سيتم تحميل البرامج النصية للمحتوى فيها ، ولتحديد عناوين URL التي يجب إضافة webRequest
المستمعين إليها.
APIs that use match patterns usually accept a list of match patterns, and will perform the appropriate action if the URL matches any of the patterns. See, for example, the content_scripts
key in manifest.json.
عادة ما تقبل واجهات برمجة التطبيقات التي تستخدم أنماط المطابقة قائمة بأنماط المطابقة، وستنفذ الإجراء المناسب إذا تطابق عنوان URL مع أي من الأنماط. انظر ، على سبيل المثال ، content_scripts
المفتاح في manifest.json.
Match pattern structure بنية نمط المطابقة
Note: Some browsers don't support certain schemes.
Check the Browser compatibility table for details.
ملاحظة: لا تدعم بعض المتصفحات أنظمة معينة. راجع جدول توافق المتصفح للحصول على التفاصيل.
All match patterns are specified as strings. Apart from the special <all_urls>
pattern, match patterns consist of three parts: scheme, host, and path. The scheme and host are separated by ://
.
يتم تحديد جميع أنماط المطابقة كسلاسل. بصرف النظر عن النمط الخاص <all_urls>
، تتكون أنماط المطابقة من ثلاثة أجزاء: المخطط والمضيف والمسار. يتم فصل المخطط والمضيف بواسطة ://
.
<scheme>://<host><path>
scheme نظام
The scheme component may take one of two forms:
قد يتخذ مكون المخطط أحد شكلين:
Form شكل | Matches مباريات |
---|---|
* |
Only "http" and "https" and in some browsers also
"ws" and "wss".
فقط "http" و "https" وفي بعض المتصفحات أيضا "ws" و "wss". |
One of http , https , ws ,
wss , ftp , data ,
file , or (chrome-)extension .
واحد من http ، https ، ws ، wss ftp ، data ، file ، ، أو (chrome-)extension . |
Only the given scheme. فقط المخطط المحدد. |
host مضيف
The host component may take one of three forms:
قد يتخذ المكون المضيف أحد الأشكال الثلاثة:
Form شكل | Matches مباريات |
---|---|
* |
Any host. أي مضيف. |
*. followed by part of the hostname.*. متبوعا بجزء من اسم المضيف. |
The given host and any of its subdomains. المضيف المحدد وأي من نطاقاته الفرعية. |
A complete hostname, without wildcards. اسم مضيف كامل ، بدون أحرف بدل. |
Only the given host. فقط المضيف المحدد. |
host must not include a port number.
يجب ألا يتضمن المضيف رقم منفذ.
host is optional only if the scheme is "file".
المضيف اختياري فقط إذا كان المخطط "ملف".
Note that the wildcard may only appear at the start.
لاحظ أن حرف البدل قد يظهر فقط في البداية.
path مسار
The path component must begin with a /
.
يجب أن يبدأ مكون المسار ب /
.
After that, it may subsequently contain any combination of the *
wildcard and any of the characters that are allowed in URL paths or query strings. Unlike host, the path component may contain the *
wildcard in the middle or at the end, and the *
wildcard may appear more than once.
بعد ذلك ، قد يحتوي لاحقا على أي مجموعة من حرف البدل *
وأي من الأحرف المسموح بها في مسارات URL أو سلاسل الاستعلام. على عكس المضيف ، قد يحتوي مكون المسار على حرف البدل *
في المنتصف أو في النهاية ، وقد يظهر حرف البدل *
أكثر من مرة.
The value for the path matches against the string which is the URL path plus the URL query string. This includes the ?
between the two, if the query string is present in the URL. For example, if you want to match URLs on any domain where the URL path ends with foo.bar
, then you need to use an array of Match Patterns like ["*://*/*foo.bar", "*://*/*foo.bar?*"]
. The ?*
is needed, rather than just bar*
, in order to anchor the ending *
as applying to the URL query string and not some portion of the URL path.
تتطابق قيمة المسار مع السلسلة التي هي مسار URL بالإضافة إلى سلسلة استعلام URL. يتضمن ذلك ?
بين الاثنين ، إذا كانت سلسلة الاستعلام موجودة في عنوان URL. على سبيل المثال ، إذا كنت تريد مطابقة عناوين URL على أي مجال ينتهي فيه مسار عنوان URL ب foo.bar
، فأنت بحاجة إلى استخدام مجموعة من أنماط المطابقة مثل ["*://*/*foo.bar", "*://*/*foo.bar?*"]
. هناك ?*
حاجة ، وليس فقط bar*
، من أجل تثبيت النهاية *
على أنها تنطبق على سلسلة استعلام URL وليس جزءا من مسار URL.
Neither the URL fragment identifier, nor the #
which precedes it, are considered as part of the path.
لا يعتبر معرف جزء عنوان URL ولا #
الذي يسبقه جزءا من المسار.
Note: The path pattern string should not include a port number. Adding a port, as in: http://localhost:1234/*
causes the match pattern to be ignored. However, http://localhost:1234
will match with http://localhost/*
.
ملاحظة: يجب ألا تتضمن سلسلة نمط المسار رقم منفذ. تؤدي إضافة منفذ، كما في: http://localhost:1234/*
إلى تجاهل نمط التطابق. ومع ذلك ، http://localhost:1234
سوف تتطابق مع http://localhost/*
.
<all_urls>
The special value <all_urls>
matches all URLs under any of the supported schemes: that is "http", "https", "ws", "wss", "ftp", "data", and "file".
تتطابق القيمة <all_urls>
الخاصة مع جميع عناوين URL ضمن أي من المخططات المدعومة: أي "http" و "https" و "ws" و "wss" و "ftp" و "data" و "file".
امثله
رسم | أمثلة على التطابقات | مثال على حالات عدم التطابق |
---|---|---|
تطابق جميع عناوين URL. |
|
|
|
|
|
|
|
|
|
|
|
|
ftp://mozilla.org |
|
|
|
|
|
|
|
|
|
|
|
|
أي شيء آخر. |
|
|
|
|
|
file:///bleh/ (مسار لا مثيل له) |
أنماط المطابقة غير الصالحة
نمط غير صالح | سبب |
---|---|
resource://path/ |
مخطط غير مدعوم. |
https://mozilla.org |
لا يوجد مسار. |
https://mozilla.*.org/ |
يجب أن يكون "*" في المضيف في البداية. |
https://*zilla.org/ |
يجب أن يكون "*" في المضيف هو الحرف الوحيد أو أن يتبعه ".". |
http*://mozilla.org/ |
يجب أن يكون "*" في المخطط هو الحرف الوحيد. |
https://mozilla.org:80/ |
يجب ألا يتضمن المضيف رقم منفذ. |
*://* |
مسار فارغ: يجب أن يكون هذا " *://*/* ". |
file://* |
مسار فارغ: يجب أن يكون هذا " file:///* ". |
توافق المتصفح
الإبلاغ عن مشاكل في بيانات التوافق هذه على GitHub
سطح المكتب | جوال | ||||||
---|---|---|---|---|---|---|---|
data | |||||||
file | |||||||
ftp | |||||||
http | |||||||
https | |||||||
مخطط أحرف * البدل | |||||||
* المباريات ws و wss | |||||||
ws | |||||||
wss |
Legend
معلومه- سرية: يمكنك النقر / النقر فوق خلية لمزيد من المعلومات.
- Full support
- دعم كامل
- Partial support
- دعم جزئي
- No support
- لا يوجد دعم