codereport / jsource

J Language Source Code. Livestream links ⬇️
https://www.youtube.com/playlist?list=PLVFrD1dmDdvfVhYLU_iKkV67X9XqCJLWe
Other
38 stars 20 forks source link

jepath won't work with relative paths which include ".." #169

Open juntuu opened 3 years ago

juntuu commented 3 years ago

The behaviour is changed when using util::remove_all_occurrences(path, "../");, which does not "back off", but only removes ..s. https://github.com/codereport/jsource/blob/6ae660de8bff9db8d3e000bd4f25974acf17d09f/jsrc/jeload.cpp#L147-L149

This would be easiest to do with std::filesystem::path::lexically_normal.

The broken behaviour now:

Given path: "/one/two/../three/"
expected:   "/one/three/"
actual:     "/one/two/three/"

This then fails to load when given relative path with ..

$> ../build/jsrc/Debug/jconsole
Hello YouTube Viewers, all 22 of you!
ERROR   Could not open library globally: dlopen(<path to>/jsource/jsrc/build/jsrc/Debug/libj.dylib, 1): image not found