asciidocfx / AsciidocFX

Asciidoc Editor and Toolchain written with JavaFX 21 (Build PDF, Epub, Mobi and HTML books, documents and slides)
http://www.asciidocfx.com/
Apache License 2.0
1.9k stars 299 forks source link

WindowsPath can not handle colons (:) in template download #569

Closed gillesB closed 1 year ago

gillesB commented 1 year ago

Hello,

the current implementation of the template download does not work under Windows. The problem is the first colon in a URL, when the filename should be retrieved via the Path API.

java.nio.file.InvalidPathException: Illegal char <:> at index 5: https://github.com/asciidocfx/Asciidoc-Book-Demo
    at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
    at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
    at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
    at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
...

As a simple workaround, the first colon is removed if the location start with http: or https:. I am not sure if this is the best way, but handling this correctly, not knowing if the String is a WindowsPath, PosixPath or URL is quite hard.

rahmanusta commented 1 year ago

I think we should resolve the proper path for each condition separately, instead of replacing the colon(:).

gillesB commented 1 year ago

Closing as this was resolved with https://github.com/asciidocfx/AsciidocFX/commit/4414eea3647eef29af49dd93349a20631e0bdfac

Thank you.