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

Failed to find epub resource path. #1322

Closed
ux-ui opened this issue Mar 5, 2023 · 4 comments
Closed

Failed to find epub resource path. #1322

ux-ui opened this issue Mar 5, 2023 · 4 comments

Comments

@ux-ui
Copy link

ux-ui commented Mar 5, 2023

Paths starting with "./" in the epub resource.

In the process of changing to blob,

"./" I can't load the file because it's changed without including the text.

"./" Is there any way to change url including?

I'm in a hurry.

@johnfactotum
Copy link
Contributor

You could either

  • Serve your EPUB unpacked, so there would be no need to use blob URLs.
  • Use Epub.js v0.4. Unlike, v0.3, it uses service workers instead of blob URLs.

Otherwise, you'd have to modify v0.3 to account for . and .. when replacing URLs. However, note that it is possible for a single URL to contain multiple . and .., which means you'd have to replace an infinite amount of URLs, which would be impossible.

So to fix this without using a server or service workers, I think it really needs to properly parse the HTML and get all href, src, etc. and then resolve and replace the whole URL in each instance. This is the approach I chose in my own EPUB library: https://github.com/johnfactotum/foliate-js/blob/dee64c19bb1a8922a7f3d060875e927e24eba5b0/epub.js#L502-L572

@ux-ui
Copy link
Author

ux-ui commented Mar 5, 2023

How do I use Epub.js v0.4?

How do I load files through the service worker?

@johnfactotum
Copy link
Contributor

Take a look at the v0.4 branch: https://github.com/futurepress/epub.js/tree/v0.4. AFAICT v0.4 is still work in progress, and I haven't tried it myself.

Also, you might be able use v0.3 and implement the service worker part yourself. It's similar to serving unpacked EPUBs with a server, except the service worker works on the client side.

IMO using service workers is not really ideal, though, as it's not really something a service worker is designed to do, but more like abusing its ability to intercept requests. It would be much better and easier to just set up a real server.

@ux-ui
Copy link
Author

ux-ui commented Mar 5, 2023

to appreciate the solution

Thank you for your answer.

I have a headache.

First of all, I think we should look for the implementation of the service worker again!

Is there a bunch of code that could be an example?

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

No branches or pull requests

2 participants