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

Integrate crate Url + routing refactor #253

Conversation

MartinKavik
Copy link
Member

@MartinKavik MartinKavik commented Oct 19, 2019

@David-OConnor
I tried to refactor routing a little bit.
I don't want to merge this PR because it uses crate Url in the one of methods and this library increases WASM file size too much (servo/rust-url#557).
PR (almost) doesn't change logic, only code style, so you can pick your "favorite" parts and implement them in your original PR. Only critical change which should be moved into original PR is #[test] -> #[wasm_bindgen_test] because these tests are ignored at the moment.
PR is quite short, ask questions if something doesn't make sense. Thanks.

(OT: It seems that it's not possible to set PR as Draft, once created)

use super::*;

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to leave this annotation in as well so that both test and wasm_bindgen_test are available? Just curious.

Copy link
Member Author

Choose a reason for hiding this comment

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

With both:

  • cargo make test_h_firefox seems to work.
  • cargo test seems to run test successfully, then fails on some errors

So it seems to work at least for tests which doesn't need browser to run.

@David-OConnor
Copy link
Member

As you noticed from a comment about Regex in the original PR, it's unfortunate we have to handwrite code that would be better suited to a dependency, especially given Rust's philosophy of keeping the standard library small.

Re the test tag: It's too bad we can't just use normal tags for code that doesn't need wasm.

@David-OConnor
Copy link
Member

I like your code integrating Url's built-in parsing; would love to replace the current code with this if the WASM-size increase can be minimized. I fixed the tests per your changes on the main PR.

@MartinKavik
Copy link
Member Author

I fixed the tests per your changes on the main PR.

Just note - I've changed also these two things:

  1. "/path/#hash?sea=rch" -> "/path?sea=rch#hash"
    • Everything after hash is ignored from the server point of view (it only lives in browser), so crate rust-url returns search == None in your original case, because search's main purpose is to send parameters to backend.
  2. "/path/#hash" -> "/path#hash" (trailing slash in more cases)
    • Crate rust-url returns also trailing empty string in path segments so you can differentiate between files and directories. It's the second difference between Seed's behavior and that library.

@MartinKavik
Copy link
Member Author

I'm closing it because of #226 (comment). We can reopen it / create a new PR once we have more lightweight URL library.

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

Successfully merging this pull request may close these issues.

3 participants