astro-indexnow 2.3.7 → 2.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD CHANGED
@@ -6,7 +6,7 @@ to **IndexNow** after each build.
6
6
  This package is designed for **modern CI/CD pipelines**, **Docker-based deployments**, and
7
7
  **large static sites**, while remaining fully deterministic and explicit.
8
8
 
9
- > **Current release:** v2.3.7
9
+ > **Current release:** v2.3.8
10
10
  > **Stateful by design. `changed` by default, `all` available. Batch-safe. CI-aware.**
11
11
 
12
12
  ---
@@ -314,6 +314,10 @@ The directory where the `.astro-indexnow-cache.json` file will be stored. Can be
314
314
 
315
315
  Example: `./node_modules/.astro`
316
316
 
317
+ The `site` value in Astro config may include a path prefix, such as `https://example.com/blog`. The integration preserves that base path when building submission URLs.
318
+
319
+ Submitted URLs use the canonical no-trailing-slash form for generated pages, except for the site root itself.
320
+
317
321
  ---
318
322
 
319
323
  ### `submissionMode` (optional)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAM9C,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAsVlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAM9C,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CA2WlB"}
package/dist/index.js CHANGED
@@ -82,6 +82,19 @@ export default function indexNow(options = {}) {
82
82
  function sleep(ms) {
83
83
  return new Promise((resolve) => setTimeout(resolve, ms));
84
84
  }
85
+ function normalizeSiteUrl(value) {
86
+ const url = new URL(value);
87
+ const normalizedPath = url.pathname.replace(/\/+$/, "").replace(/\/+/g, "/");
88
+ url.pathname = normalizedPath || "/";
89
+ return url.toString().replace(/\/$/, "");
90
+ }
91
+ function normalizeSubmittedUrl(value) {
92
+ const url = new URL(value);
93
+ if (url.pathname !== "/") {
94
+ url.pathname = url.pathname.replace(/\/+$/, "");
95
+ }
96
+ return url.toString();
97
+ }
85
98
  function isQuiet() {
86
99
  return options.logMode === "quiet";
87
100
  }
@@ -152,8 +165,11 @@ export default function indexNow(options = {}) {
152
165
  ----------------------------------------------- */
153
166
  "astro:config:setup": ({ config, logger }) => {
154
167
  site =
155
- options.siteUrl ??
156
- (config.site ? config.site.replace(/\/$/, "") : null);
168
+ options.siteUrl
169
+ ? normalizeSiteUrl(options.siteUrl)
170
+ : config.site
171
+ ? normalizeSiteUrl(config.site)
172
+ : null;
157
173
  logVerbose(logger, `project root: ${projectRoot}`);
158
174
  ensureCacheFile(logger);
159
175
  },
@@ -188,7 +204,7 @@ export default function indexNow(options = {}) {
188
204
  .relative(outDir, fullPath)
189
205
  .replace(/index\.html$/, "")
190
206
  .replace(/\\/g, "/");
191
- const url = site + "/" + relativePath.replace(/^\/+/, "");
207
+ const url = normalizeSubmittedUrl(new URL(relativePath.replace(/^\/+/, ""), `${site}/`).toString());
192
208
  const hash = hashFile(fullPath);
193
209
  // Cache by URL because IndexNow submits URLs, not filesystem paths.
194
210
  nextCache[url] = hash;
@@ -241,13 +257,13 @@ export default function indexNow(options = {}) {
241
257
  anyBatchFailed = true;
242
258
  }
243
259
  }
244
- saveCache(logger, nextCache);
245
260
  if (anyBatchFailed) {
246
261
  logWarn(logger, `IndexNow submission failed`);
262
+ logWarn(logger, "cache left unchanged because one or more submissions failed");
263
+ return;
247
264
  }
248
- else {
249
- logInfo(logger, `IndexNow submission complete`);
250
- }
265
+ saveCache(logger, nextCache);
266
+ logInfo(logger, `IndexNow submission complete`);
251
267
  },
252
268
  },
253
269
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-indexnow",
3
- "version": "2.3.7",
3
+ "version": "2.3.8",
4
4
  "description": "Astro integration to submit pages to IndexNow automatically after build",
5
5
  "type": "module",
6
6
  "exports": {