Open danyill opened 2 years ago
I think this fix needs to happen in Opal. File.$join needs to detect //
at the start of the path and restore it after running path.join. By itself, path.join (or path.posix.join) normalizes the leading //
to /
.
The "default" implementation in Opal is actually doing a better job (on this particular case): https://github.com/opal/opal/blob/6ad0f920e49df8e3f280286f01b2f0993f47d759/opal/corelib/file.rb#L173-L204
$ opal -e "puts File.join('//a', 'b')"
//a/b
$ opal --require nodejs -e "puts File.join('//a', 'b')"
/a/b
Upstream issue: https://github.com/opal/opal/issues/2348
Fix available in Opal 1.4.0
Actually this is not enough.
@mojavelinux I think we should also update absolute_path?
to return true when the path starts with \\
or //
(normalized):
I'm trying to diagnose an issue with path resolution if data-uri is set for network shares and UNC paths.
I provide a
base_dir
to Asciidoctor.js of:\\wnfs1\groups\prot_pai\_112_Files\8 Projects\KMO-TMI-OWH-TRK-protection-replacements-2021-2023\Vivian\Adoc
I receive error messages along the lines of:
What seems to be important is that it is reporting the path as having a single leading slash.
This occurs when
normalize_system_path
is called which calls below:start = $$$('::', 'File').$join(doc.$base_dir(), start)
$join
removes one of the leading/
at the start of the filename.Here are some outputs:
$join
is defined as:This assumes the path is a posix path and removes the leading
/
:This is destructive of UNC paths which is why Asciidoctor cannot resolve the image (and other resources) when
data-uri
is set.We discussed this on Zulip and Dan helped me identify that this was part of Opal/Asciidoctor.js and there were tests for this situation in Asciidoctor Ruby.