Skip to content

fix: RawImage.fromURL error when input file url #1288

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

himself65
Copy link

@himself65 himself65 commented Apr 16, 2025

Upstream: run-llama/LlamaIndexTS#1855

fs.existSync(path) will assume path is a posix/win32 format if you give a string, so you will need pass url.pathname

@himself65
Copy link
Author

himself65 commented Apr 21, 2025

/cc @xenova do you have a change to look at this? /

@xenova
Copy link
Collaborator

xenova commented Apr 21, 2025

Hi @himself65 👋 Can you give an example of a URL which has this problem? The if clause should not allow invalid URLs to pass this step.

@himself65
Copy link
Author

himself65 commented Apr 21, 2025

Hi @himself65 👋 Can you give an example of a URL which has this problem? The if clause should not allow invalid URLs to pass this step.

Yes, we were using file: protocol in node.js, and file protocol is a standard in node.js. And this is a regression because our test is working in <=4.0.0

const imageUrl = new URL(
  "../../fixtures/img/llamaindex-white.png",
  import.meta.url,
);

const nodes = [
  new ImageNode({
    image: imageUrl,
  }),
];

@himself65
Copy link
Author

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.

2 participants