nitropack-nightly 2.11.0-20250205-132346.c99b22fd → 2.11.0-20250205-154318.5a80d3d4

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.
@@ -38,6 +38,7 @@ import { version } from 'nitropack/meta';
38
38
  import { gzipSize } from 'gzip-size';
39
39
  import prettyBytes from 'pretty-bytes';
40
40
  import zlib from 'node:zlib';
41
+ import { walk, parse } from 'ultrahtml';
41
42
  import { Worker } from 'node:worker_threads';
42
43
  import { setResponseHeaders, getRequestURL, setResponseStatus, getResponseHeader, setResponseHeader, getRequestHeader, send, getRequestHeaders, eventHandler, createError, createApp, fromNodeMiddleware, toNodeListener } from 'h3';
43
44
  import { createProxyServer } from 'httpxy';
@@ -1784,7 +1785,6 @@ function isCompressibleMime(mimeType) {
1784
1785
 
1785
1786
  const allowedExtensions = /* @__PURE__ */ new Set(["", ".json"]);
1786
1787
  const linkParents$1 = /* @__PURE__ */ new Map();
1787
- const LINK_REGEX = /(?<=\s)href=(?!&quot;)["']?([^"'>]+)/g;
1788
1788
  const HTML_ENTITIES = {
1789
1789
  "&lt;": "<",
1790
1790
  "&gt;": ">",
@@ -1798,13 +1798,19 @@ function escapeHtml(text) {
1798
1798
  (ch) => HTML_ENTITIES[ch] || ch
1799
1799
  );
1800
1800
  }
1801
- function extractLinks(html, from, res, crawlLinks) {
1801
+ async function extractLinks(html, from, res, crawlLinks) {
1802
1802
  const links = [];
1803
1803
  const _links = [];
1804
1804
  if (crawlLinks) {
1805
- _links.push(
1806
- ...[...html.matchAll(LINK_REGEX)].map((m) => escapeHtml(m[1])).filter((m) => !decodeURIComponent(m).startsWith("#")).filter((link) => allowedExtensions.has(getExtension(link)))
1807
- );
1805
+ await walk(parse(html), (node) => {
1806
+ if (!node.attributes?.href) {
1807
+ return;
1808
+ }
1809
+ const link = escapeHtml(node.attributes.href);
1810
+ if (!decodeURIComponent(link).startsWith("#") && allowedExtensions.has(getExtension(link))) {
1811
+ _links.push(link);
1812
+ }
1813
+ });
1808
1814
  }
1809
1815
  const header = res.headers.get("x-nitro-prerender") || "";
1810
1816
  _links.push(...header.split(",").map((i) => decodeURIComponent(i.trim())));
@@ -2037,7 +2043,7 @@ async function prerender(nitro) {
2037
2043
  _route.skip = true;
2038
2044
  }
2039
2045
  if (!_route.error && (isImplicitHTML || route.endsWith(".html"))) {
2040
- const extractedLinks = extractLinks(
2046
+ const extractedLinks = await extractLinks(
2041
2047
  dataBuff.toString("utf8"),
2042
2048
  route,
2043
2049
  res,
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250205-154318.5a80d3d4";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250205-154318.5a80d3d4";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250205-154318.5a80d3d4";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.0-20250205-132346.c99b22fd",
3
+ "version": "2.11.0-20250205-154318.5a80d3d4",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",
@@ -159,6 +159,7 @@
159
159
  "source-map": "^0.7.4",
160
160
  "std-env": "^3.8.0",
161
161
  "ufo": "^1.5.4",
162
+ "ultrahtml": "^1.5.3",
162
163
  "uncrypto": "^0.1.3",
163
164
  "unctx": "^2.4.1",
164
165
  "unenv": "^1.10.0",