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

aways use posix paths on generated relative paths in html #206

Merged
merged 3 commits into from May 2, 2022

Conversation

aivuk
Copy link
Contributor

@aivuk aivuk commented May 1, 2022


With livemark is used in Windows, outside a POSIX compliant system the generated URLs inside the generated HTML will have Window back slashes (\folder\file instead of /folder/file). This happens because of how gel_relapath is generating the path using os.path.join. os.path always follows the format of the current OS, this means, if you are in windows it is going to use back slashes. The problem happens that urls follow POSIX path, with this slash /.

I don't know if there are other places that we need to change the paths to POSIX ones. If we just change everywhere that os.path is used, this will causes problems for windows user when livemark need to open a file somewhere.

@aivuk aivuk added the bug Something isn't working label May 1, 2022
@aivuk aivuk requested a review from roll May 1, 2022 16:53
@@ -23,7 +24,7 @@ def read_asset(*paths):


def get_relpath(path, current):
return os.path.relpath(path, os.path.dirname(current))
return posixpath.relpath(path, os.path.dirname(current))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashigharti
BTW it's a good way to solve the problem when we need "/" on windown we had similar situation with ZIP files if you remember. So we could have used this posixpath module

Copy link
Member

@roll roll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aivuk
Good catch!

I would make the solution more explicit. Currently, this function is called helpers.get_relpath. One expect that it will be a relative path on UNIX and Windows. So after the fix, this function seems to be misleading for me.

I would add a new function helpers.get_relurl/get_url_relpath/get_relative_url with this implementation and use it in the codebase (probably all the get_relpath usage needs to be replaced by the new function)

@aivuk
Copy link
Contributor Author

aivuk commented May 2, 2022

@roll I added get_url_repath and changed some places to use it, but I still haven't tested on windows. Not all places that I changed I'm sure if we need a POSIX path or the local OS one. I will test in few minutes (as soon as my Ubuntu finish upgrading and I can reboot my machine!).

@aivuk aivuk changed the title aways use poxix paths on generated relative paths in html aways use posix paths on generated relative paths in html May 2, 2022
@aivuk
Copy link
Contributor Author

aivuk commented May 2, 2022

@roll tested the branch in windows, generated the website at https://github.com/Andrelamor/erros-validacao and it worked.

Copy link
Member

@roll roll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@roll roll merged commit e230e31 into main May 2, 2022
@roll roll deleted the bug-205-use-posix-path-to-generated-urls branch May 2, 2022 11:40
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
Archived in project
Development

Successfully merging this pull request may close these issues.

URL Problems using livemark build on Windows
2 participants