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

[loader] file path issue #187

Closed
kangfenmao opened this issue Dec 24, 2024 · 2 comments
Closed

[loader] file path issue #187

kangfenmao opened this issue Dec 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kangfenmao
Copy link

kangfenmao commented Dec 24, 2024

🐛 Describe the bug

https://github.com/llm-tools/embedJs/blob/main/core/embedjs-utils/src/util/strings.ts

export function isValidURL(url: string) {
    try {
        new URL(url);
        return true;
    } catch {
        return false;
    }
}

TestCase:

url C:\README.md
return true

MarkdownLoader

this.isUrl = true

TypeError: fetch failed
[cause]: Error: unknown scheme

Here should be used file access mode to read the local directory files.

@adhityan adhityan added the bug Something isn't working label Dec 27, 2024
@adhityan
Copy link
Collaborator

Thank you for pointing the bug out. Updated signature to following in the upcoming release -

export function isValidURL(url: string) {
    try {
        const parsedUrl = new URL(url);
        return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
    } catch {
        return false;
    }
}

@adhityan
Copy link
Collaborator

Addressed in 0.1.26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants