@maravilla-labs/adapter-sveltekit 0.1.15 → 0.1.16

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.
@@ -35,6 +35,14 @@ async function handleRequest(request) {
35
35
  // Ensure server is initialized
36
36
  await initialized;
37
37
 
38
+ // The runtime should have already set globalThis.location by now
39
+ // Log it for debugging
40
+ if (globalThis.location) {
41
+ console.log('globalThis.location is available:', globalThis.location.origin);
42
+ } else {
43
+ console.warn('WARNING: globalThis.location not set by runtime - this may cause URL resolution issues');
44
+ }
45
+
38
46
  // Check if request is already a Web API Request object
39
47
  let webRequest;
40
48
  if (request instanceof Request) {
@@ -67,13 +75,15 @@ async function handleRequest(request) {
67
75
  }
68
76
 
69
77
  // Check if this is a static asset request
70
- const pathname = new URL(webRequest.url).pathname;
78
+ // Use a base URL to avoid "relative URL without a base" errors
79
+ const requestUrl = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');
80
+ const pathname = requestUrl.pathname;
71
81
  const stripped_pathname = pathname.replace(/\\/$/, '');
72
82
 
73
83
  // Debug: verify URL.pathname setter works for data requests
74
84
  if (pathname.endsWith('/__data.json') || pathname.endsWith('.html__data.json')) {
75
85
  try {
76
- const test = new URL(webRequest.url);
86
+ const test = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');
77
87
  const before = test.pathname;
78
88
  const candidate = pathname.endsWith('/__data.json')
79
89
  ? pathname.slice(0, -'/__data.json'.length)
@@ -94,7 +104,7 @@ async function handleRequest(request) {
94
104
  // Handle trailing slash redirects for prerendered pages
95
105
  const location = pathname.at(-1) === '/' ? stripped_pathname : pathname + '/';
96
106
  if (location && prerendered.has(location)) {
97
- const urlObj = new URL(webRequest.url);
107
+ const urlObj = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');
98
108
  return new Response('', {
99
109
  status: 308,
100
110
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maravilla-labs/adapter-sveltekit",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "SvelteKit adapter for Maravilla Runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",