@standardagents/builder 0.19.3 → 0.20.1

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/dist/plugin.js CHANGED
@@ -7313,9 +7313,24 @@ function platformLoginUrl(request, env) {
7313
7313
  return url.toString();
7314
7314
  }
7315
7315
 
7316
+ function isUiNavigationPath(pathname) {
7317
+ if (!pathname || pathname === '/') return true;
7318
+ if (pathname.startsWith('/api/')) return false;
7319
+ const lastSegment = pathname.split('/').pop() || '';
7320
+ return !lastSegment.includes('.');
7321
+ }
7322
+
7316
7323
  function isHtmlNavigationRequest(request) {
7317
7324
  if (request.method !== 'GET' && request.method !== 'HEAD') return false;
7318
- return (request.headers.get('Accept') || '').includes('text/html');
7325
+ const accept = (request.headers.get('Accept') || '').toLowerCase();
7326
+ if (accept.includes('text/html')) return true;
7327
+
7328
+ const fetchDest = (request.headers.get('Sec-Fetch-Dest') || '').toLowerCase();
7329
+ if (fetchDest === 'document') return true;
7330
+ if (fetchDest && fetchDest !== 'empty') return false;
7331
+
7332
+ const pathname = new URL(request.url).pathname || '/';
7333
+ return (accept === '' || accept === '*/*') && isUiNavigationPath(pathname);
7319
7334
  }
7320
7335
 
7321
7336
  // CORS headers for API responses