Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use URL global in parseUri #162

Closed
wants to merge 2 commits into from
Closed

Use URL global in parseUri #162

wants to merge 2 commits into from

Conversation

jokull
Copy link

@jokull jokull commented Jan 24, 2024

Reproduction

  1. Start a new next.js app router project (e.g. bun create next-app)
  2. Add app/test/route.ts
  3. Add this
import { createClient } from "@libsql/client/web";
import { NextResponse } from "next/server";

export const runtime = "edge";

export async function GET() {
  const statement = await createClient({
    url: "http://127.0.0.1:8080",
  }).execute("SELECT 1");
  return NextResponse.json(statement.toJSON());
}

Run bun run build.

@jokull
Copy link
Author

jokull commented Jan 29, 2024

Dug into some tests. I don't believe the global URL class will handle the following URL's found in tests without some special cases and RegEx detection:

  1. file://localhost - and its variants, because URL seems to have some special handling around not wanting to interpret hostnames
  2. file: with relative paths
  3. An empty path in any URL will get overwritten as the root / path

I'm no longer convinced my proposal is viable. It will need much more work to become backwards compatible and I don't have time for that right now.

@giovannibenussi
Copy link
Contributor

Thanks a lot for your help with this. This is really useful for us because we still need to fix the issue with Next.js so your insights help us a lot!

I want to test out two different ideas. The first one is to look for an already built 3986 parser like elysiumphase/node-uri as a replacement and the second idea is to find a workaround for the regex.

@penberg
Copy link
Contributor

penberg commented Feb 1, 2024

Fixed by #172 so closing this PR.

@penberg penberg closed this Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants