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

bug with rendering urls in <a> tags #9

Closed
wmacmillan opened this issue Jul 4, 2021 · 3 comments
Closed

bug with rendering urls in <a> tags #9

wmacmillan opened this issue Jul 4, 2021 · 3 comments

Comments

@wmacmillan
Copy link

wmacmillan commented Jul 4, 2021

Howdy. There seems to be some issue rendering the href tag, at least in <a> tags. If you include query parameters it cuts off the link past the ?, if you include https://. See below.

Note, the link does work if put into resulting html correctly (meaning, with the query).

from domonic import a, render

if __name__ == "__main__":

    urls = [
      'example.com/stuff?things=morestuff',
      'https://example.com/stuff?things=morestuff',
      'https://example.com/stuff',
      'https://www.example.com/stuff?thing',
      'https://www.example.com/?stuff'
    ]

    for url in urls:
        print(
            f'''
---------
Renders as: {render(a(_href=url))}
 should be: <a href="{url}"></a>
---------'''
        )

results in the following:

---------
Renders as: <a href="example.com/stuff?things=morestuff"></a>
 should be: <a href="example.com/stuff?things=morestuff"></a>
---------

---------
Renders as: <a href="https://example.com/stuff"></a>
 should be: <a href="https://example.com/stuff?things=morestuff"></a>
---------

---------
Renders as: <a href="https://example.com/stuff"></a>
 should be: <a href="https://example.com/stuff?thing"></a>
---------

---------
Renders as: <a href="https://www.example.com/stuff"></a>
 should be: <a href="https://www.example.com/stuff?thing"></a>
---------

---------
Renders as: <a href="https://www.example.com/"></a>
 should be: <a href="https://www.example.com/?stuff"></a>
---------
@byteface
Copy link
Owner

byteface commented Jul 4, 2021

very sorry. query params has been on my mind a while for this tag. (i kinda supsected this might happen) i recently did URLSearchParams so hopefully can fix this up asap. thanks so much for reporting it.

@byteface
Copy link
Owner

byteface commented Jul 4, 2021

thank you so much. this is now fixed in 0.3.16 and I've added your code to the unit test with assertions.

python -m unittest tests.test_html.domonicTestCase.test_domonic_render_a_tag_query_params

@byteface byteface closed this as completed Jul 4, 2021
@wmacmillan
Copy link
Author

Thank you for the useful code! Happy to contribute.

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