aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/plugins/create-manifest-webpack-plugin/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/webpack/plugins/create-manifest-webpack-plugin/index.js')
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/index.js23
1 files changed, 19 insertions, 4 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
index e28c695..99feb58 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
@@ -7,6 +7,13 @@ import { getFileName } from "../../utils/build-file.js";
import { getScriptRuntimeFromType } from "../../utils/script-runtime.js";
import scripts from "../../utils/scripts.js";
+/** The only host this extension ever touches, used for every match pattern. */
+const SITE_HOST = "banglarbhumi.gov.in";
+/** Site-wide access: covers `web_accessible_resources` and `host_permissions`. */
+const SITE_MATCH = `*://${SITE_HOST}/*`;
+/** The application section of the site, where every content script runs. */
+const APP_MATCH = `*://${SITE_HOST}/BanglarBhumi/*`;
+
const manifest = JSON.parse(
fs.readFileSync(
path.resolve("config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json")
@@ -21,6 +28,10 @@ const manifest = JSON.parse(
* page URL patterns. Shared modules, injected scripts, and
* web-accessible resources are added automatically based on import
* counts collected during the build.
+ *
+ * Every generated pattern is scoped to {@link SITE_HOST}: match patterns
+ * allow a single trailing `*` in the path, so the `"*"` script path maps to
+ * {@link APP_MATCH} rather than the invalid `BanglarBhumi/**`.
*/
class CreateManifestPlugin {
/**
@@ -72,7 +83,7 @@ class CreateManifestPlugin {
}
manifest.content_scripts.push({
- matches: ["*://banglarbhumi.gov.in/BanglarBhumi/*"],
+ matches: [APP_MATCH],
js: this.sortedSharedModules
.filter((sharedModule) => this.sharedModulesImportedCount[sharedModule] > 0)
.map((sharedModule) => `shared/${getFileName(sharedModule, "shared")}.js`)
@@ -84,10 +95,14 @@ class CreateManifestPlugin {
delete arrangedScripts["*"]["document_start"];
for (const scriptPath in arrangedScripts) {
- const matches = [`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}*`];
+ // Match patterns allow at most one trailing `*`, so `"*"` cannot
+ // be interpolated into the path the way a literal segment can.
+ const matches = [scriptPath === "*"
+ ? APP_MATCH
+ : `*://${SITE_HOST}/BanglarBhumi/${scriptPath}*`];
if (scriptPath === "Home")
- matches.push(`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}.action*`);
+ matches.push(`*://${SITE_HOST}/BanglarBhumi/${scriptPath}.action*`);
for (const scriptRuntime in arrangedScripts[scriptPath]) {
manifest.content_scripts.push({
@@ -125,7 +140,7 @@ class CreateManifestPlugin {
manifest.web_accessible_resources = [
{
resources,
- matches: ["<all_urls>"]
+ matches: [SITE_MATCH]
}
];
}