简体   繁体   中英

Vue.js - Is base url of vue-router case sensitive?

I have a Vue.js application which use vue-router module.

export default new Router({
    base: '/CDP/V2',
    mode: 'history',
    routes: [
       {
            path: '/home',
            name: 'home',
            component: HomeApp
        }
    ]
})

Is base url of vue-router case sensitive ?

And if it's yes, how can I make it case insensitive ? I want to make "V2" part non case sensitive

Thanks

Yes it's case sensitive, you could check this sample code , in order to make it insensitive try the following code :

// Define router
const router = new VueRouter({
  base: config.basePath,
  routes,
  mode: 'history'
})

// Route case-sensitivity hotfix
if (router.mode === 'history') {
  router.history.getCurrentLocation = function() {
    let path = window.location.pathname
    let base = router.history.base

    // Removes base from path (case-insensitive)
    if (base && path.toLowerCase().indexOf(base.toLowerCase()) === 0) {
      path = path.slice(base.length)
    }

    return (path || '/') + window.location.search + window.location.hash
  }
}

for more details check this issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM