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

Yew router path matching cannot be triggered #3517

Open
sammyne opened this issue Nov 4, 2023 · 2 comments
Open

Yew router path matching cannot be triggered #3517

sammyne opened this issue Nov 4, 2023 · 2 comments
Labels

Comments

@sammyne
Copy link

sammyne commented Nov 4, 2023

Problem

If there is already some static html occupying a path, access using url on the page won't trigger custom route matching in my app. For example, a static html file is put at path /post/hello.html, and this will make route matching arm Route::Post unmatchable

#[derive(Clone, Routable, PartialEq)]
enum Route {
    #[at("/")]
    Home,
    #[at("/post/:id")]
    Post { id: String },
    #[not_found]
    #[at("/404")]
    NotFound,
}

Steps To Reproduce

  1. Clone this repository, which stores the related codes
    git clone https://github.com/sammyne/yew-router-path-cannot-captured
    
    cd yew-router-path-cannot-captured
  2. Install tools
    rustup target add wasm32-unknown-unknown
    
    cargo install trunk wasm-bindgen-cli
  3. Start the server
    trunk serve
  4. Visit http://127.0.0.1:8080/post/hello.html,and check log in Console of DevTools.

Expected behavior
See logs post id=hello.html in Console

Screenshots
screenshot

Environment:

  • Yew version: v0.21.0
  • Yew Router version: v0.18.0
  • Rust version: 1.73.0
  • Target, if relevant: wasm32-unknown-unknown
  • Build tool, if relevant: trunk
  • OS, if relevant: Debian GNU/Linux 11 (bullseye)
  • Browser and version, if relevant: Chrome 120.0.6073.0 64-bits
@sammyne sammyne added the bug label Nov 4, 2023
@ranile
Copy link
Member

ranile commented Nov 4, 2023

What if you go to http://127.0.0.1:8080/post/hello without .html suffix? You're not getting a .html file, so the extension is not needed

@sammyne
Copy link
Author

sammyne commented Nov 6, 2023

What if you go to http://127.0.0.1:8080/post/hello without .html suffix? You're not getting a .html file, so the extension is not needed

Without .html suffix will match the /post/:id case. Why it cannot be matched with .html suffix?
I just wonder if the route won't be respected when there is a static file matching the routing path. @hamza1311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants