Skip to content

warn about root paths without a leading slash #2550

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Comments

@MatiasOlivera
Copy link

MatiasOlivera commented Dec 24, 2018

Version

2.5.3

Reproduction link

https://codesandbox.io/s/6zvmx5lorr

Example

import Vue from "vue";
import Router from "vue-router";

import Home from "../src/views/Home.vue";
import Products from "../src/views/Products.vue";

Vue.use(Router);

const routes = [
  { name: "home", path: "/", component: Home },
  {
    name: "products",
    path: "products", // <-- the problem is here
    component: Products
  }
];

export default new Router({
  routes
});

Steps to reproduce

  1. Open the reproduction
  2. Click on the products link

What is expected?

I spent some time trying to understand what the problem was, so it would be nice to see a warning message telling that the route is invalid because doesn't have the initial slash.

What is actually happening?

The router goes to a route that doesn't exist.

@posva posva changed the title Path without slash warn about root paths without a leading slash Dec 24, 2018
@Zarad1993
Copy link

Can I work on this?

@thedamon
Copy link

thedamon commented Feb 5, 2019

Would be nice to see a note in the docs about how slashes should be used in routes.. or did I miss one?

@nmfzone
Copy link

nmfzone commented Mar 11, 2019

Any update on this? I think it's should be mentioned in docs if leading slash (in path) is mandatory.
This will make some confusion for new user..

@posva posva added the has PR label Mar 26, 2019
posva pushed a commit that referenced this issue Aug 30, 2019
* fix(create-matcher): warn about root paths without a leading slash

close #2550

* fix(create-route-map): warn about root paths without a leading slash

close #2550

* fix(create-route-map): only warn about first route without slash

* fix(create-route-map): handle case of '' route

* fix(create-route-map): remove leftover console.log

* fix(create-route-map): warn about root paths only

* fix(create-route-map): show prettier warning message
# for free to join this conversation on GitHub. Already have an account? # to comment