Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Bạn sử dụng danh sách cho phép để chỉ định các URL cụ thể được phê duyệt trước để tập lệnh hoặc tiện ích bổ sung của bạn truy cập. Danh sách cho phép giúp bảo vệ dữ liệu người dùng; khi bạn xác định danh sách cho phép, các dự án tập lệnh sẽ không thể truy cập vào những URL chưa được thêm vào danh sách cho phép.
Bạn không bắt buộc phải điền trường này khi cài đặt bản triển khai kiểm thử, nhưng bắt buộc phải điền khi tạo bản triển khai có phiên bản.
Bạn sử dụng danh sách cho phép khi tập lệnh hoặc tiện ích bổ sung của bạn thực hiện các thao tác sau:
Truy xuất hoặc tìm nạp thông tin từ một vị trí bên ngoài (chẳng hạn như các điểm cuối HTTPS) bằng dịch vụ UrlFetch của Apps Script. Để đưa các URL vào danh sách cho phép để tìm nạp, hãy thêm trường urlFetchWhitelist vào tệp kê khai.
Mở hoặc hiển thị một URL để phản hồi hành động của người dùng (Bắt buộc đối với những tiện ích bổ sung Google Workspace mở hoặc hiển thị các URL bên ngoài Google). Để đưa các URL vào danh sách cho phép để mở, hãy thêm trường addOns.common.openLinkUrlPrefixes vào tệp kê khai của bạn.
Thêm tiền tố vào danh sách cho phép
Khi chỉ định danh sách cho phép trong tệp kê khai (bằng cách thêm trường addOns.common.openLinkUrlPrefixes hoặc urlFetchWhitelist), bạn phải thêm danh sách tiền tố URL. Các tiền tố mà bạn thêm vào tệp kê khai phải đáp ứng các yêu cầu sau:
Mỗi tiền tố phải là một URL hợp lệ.
Mỗi tiền tố phải sử dụng https://, chứ không phải http://.
Mỗi tiền tố phải có một miền đầy đủ.
Mỗi tiền tố phải có một đường dẫn không trống. Ví dụ: https://www.google.com/ là hợp lệ nhưng https://www.google.com thì không.
Bạn có thể sử dụng ký tự đại diện để so khớp tiền tố miền phụ của URL.
Bạn có thể dùng một ký tự đại diện * trong trường addOns.common.openLinkUrlPrefixes để so khớp tất cả các đường liên kết, nhưng bạn không nên làm như vậy vì việc này có thể khiến dữ liệu của người dùng gặp rủi ro và có thể kéo dài quy trình xem xét tiện ích bổ sung. Chỉ sử dụng ký tự đại diện nếu chức năng của tiện ích bổ sung yêu cầu.
Khi xác định xem một URL có khớp với tiền tố trong danh sách cho phép hay không, các quy tắc sau sẽ được áp dụng:
Tính năng so khớp đường dẫn có phân biệt chữ hoa chữ thường.
Nếu tiền tố giống hệt với URL, thì đó là một kết quả trùng khớp.
Nếu URL giống với tiền tố hoặc là một phần của tiền tố, thì đó là một kết quả khớp.
Ví dụ: tiền tố https://example.com/foo khớp với các URL sau:
https://example.com/foo
https://example.com/foo/
https://example.com/foo/bar
https://example.com/foo?bar
https://example.com/foo#bar
Sử dụng ký tự đại diện
Bạn có thể dùng một ký tự đại diện (*) để so khớp một miền con cho cả trường urlFetchWhitelist và addOns.common.openLinkUrlPrefixes. Bạn không thể dùng nhiều ký tự đại diện để so khớp nhiều miền con và ký tự đại diện phải đại diện cho tiền tố đầu tiên của URL.
Ví dụ: tiền tố https://*.example.com/foo khớp với các URL sau:
https://subdomain.example.com/foo
https://any.number.of.subdomains.example.com/foo
Tiền tố https://*.example.com/fookhông khớp với các URL sau:
https://subdomain.example.com/bar (hậu tố không khớp)
https://example.com/foo (bạn phải cung cấp ít nhất một miền con)
Một số quy tắc về tiền tố sẽ được thực thi khi bạn cố gắng lưu tệp kê khai. Ví dụ: các tiền tố sau đây sẽ gây ra lỗi nếu có trong tệp kê khai khi bạn cố gắng lưu:
https://*.*.example.com/foo (không được dùng nhiều ký tự đại diện)
https://subdomain.*.example.com/foo
(bạn phải sử dụng ký tự đại diện làm tiền tố chính)
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eAllowlists specify approved URLs for your script or add-on to access, enhancing user data protection by restricting access to unlisted URLs.\u003c/p\u003e\n"],["\u003cp\u003eAllowlists are necessary for scripts that fetch external data or open external links, especially for versioned deployments and Google Workspace Add-ons.\u003c/p\u003e\n"],["\u003cp\u003eWhen defining allowlists, use HTTPS prefixes with full domains, non-empty paths, and optional wildcards for subdomains, ensuring adherence to specific formatting rules.\u003c/p\u003e\n"],["\u003cp\u003eAllowlist prefixes are matched against URLs based on case-sensitive path comparisons, allowing access to identical URLs or child paths of the prefix.\u003c/p\u003e\n"],["\u003cp\u003eWildcards can represent subdomains in allowlist prefixes but must be used as the leading prefix and cannot be used to match multiple subdomains simultaneously.\u003c/p\u003e\n"]]],[],null,["# Allowlist URLs\n\nYou use allowlists to designate specific URLs that are pre-approved for access\nby your script or add-on. Allowlists help protect user\ndata; when you define an allowlist, script projects can't access URLs that have\nnot been added to the allowlist.\n\nThis field is optional when you install a test deployment, but is required when\nyou create a versioned deployment.\n\nYou use allowlists when your script or add-on performs\nthe following actions:\n\n- Retrieves or fetches information from an external location (such as HTTPS endpoints) using the Apps Script [`UrlFetch`](/apps-script/reference/url-fetch) service. To allowlist URLs for fetching, include the [`urlFetchWhitelist`](/apps-script/manifest#Manifest.FIELDS.urlFetchWhitelist) field in your manifest file.\n- Opens or displays a URL in response to a user action (Required for Google Workspace add-ons that open or display URLs that are external to Google). To allowlist URLs for opening, include the [`addOns.common.openLinkUrlPrefixes`](/apps-script/manifest/addons#Common.FIELDS.openLinkUrlPrefixes) field in your manifest file.\n\n| **Note:** *Whitelist* , as used in [`urlFetchWhitelist`](/apps-script/manifest#Manifest.FIELDS.urlFetchWhitelist), is a deprecated term that is synonymous with and replaced by *allowlist* . For more information, see [Writing inclusive documentation](https://developers.google.com/style/inclusive-documentation).\n\n### Adding prefixes to your allowlist\n\nWhen you specify allowlists in your manifest file (by including either the\n`addOns.common.openLinkUrlPrefixes` or `urlFetchWhitelist` field), you must\ninclude a list of URL prefixes. The prefixes you add to the manifest must\nsatisfy the following requirements:\n\n- Each prefix must be a valid URL.\n- Each prefix must use `https://`, not `http://`.\n- Each prefix must have a full domain.\n- Each prefix must have a non-empty path. For example, `https://www.google.com/` is valid but `https://www.google.com` is not.\n- You can use [wildcards](#using_wildcards) to match URL subdomain prefixes.\n- A single `*` wildcard can be used in the [`addOns.common.openLinkUrlPrefixes`](/apps-script/manifest/addons#Common.FIELDS.openLinkUrlPrefixes) field to match all links, but this is not recommended as it can expose a user's data to risk and can prolong the [add-on review](/workspace/add-ons/concepts/gsuite-addon-review) process. Only use a wildcard if your add-on functionality requires it.\n\nWhen determining if a URL matches a prefix in the allowlist, the following rules\napply:\n\n- Path matching is case-sensitive.\n- If the prefix is identical to the URL, it is a match.\n- If the URL is the same or a child of the prefix, it is a match.\n\nFor example, the prefix `https://example.com/foo` matches the following URLs:\n\n- `https://example.com/foo`\n- `https://example.com/foo/`\n- `https://example.com/foo/bar`\n- `https://example.com/foo?bar`\n- `https://example.com/foo#bar`\n\n### Using wildcards\n\nYou can use a single wildcard character (`*`) to match a subdomain for both the\n[`urlFetchWhitelist`](/apps-script/manifest#Manifest.FIELDS.urlFetchWhitelist)\nand [`addOns.common.openLinkUrlPrefixes`](/apps-script/manifest/addons#Common.FIELDS.openLinkUrlPrefixes)\nfields. You can't use more than one wildcard to match multiple subdomains, and\nthe wildcard must represent the leading prefix of the URL.\n\nFor example, the prefix `https://*.example.com/foo` matches the following\nURLs:\n\n- `https://subdomain.example.com/foo`\n- `https://any.number.of.subdomains.example.com/foo`\n\nThe prefix `https://*.example.com/foo` *doesn't* match the following\nURLs:\n\n- `https://subdomain.example.com/bar` (suffix mismatch)\n- `https://example.com/foo` (at least one subdomain must be present)\n\nSome of the prefix rules are enforced when you try to save your manifest. For\nexample, the following prefixes cause an error if they are present in your\nmanifest when you attempt to save:\n\n- `https://*.*.example.com/foo` (multiple wildcards are forbidden)\n- `https://subdomain.*.example.com/foo` (wildcards must be used as a leading prefix)"]]