[Vuejs]-Case-insensitive router.base with nuxt.js and IIS

0👍

This doesn’t really fix the issue, but it seems one can redirect the page early in the loading process to a page with a path that starts with the router.base exactly. So in /layouts/default.vue, I now have:

export default {
  mounted () {
    let escapeRegExp = function(string) {
      return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
    }
    if (this.$route.fullPath.indexOf(this.$router.options.base) == -1 &&
        this.$route.fullPath.toLocaleLowerCase().indexOf(this.$router.options.base.toLowerCase()) == 0) {
      let base = this.$router.options.base
      let regex = new RegExp("(//[^/]+)"+escapeRegExp(base),"i")
      let newLoc = document.location.href.replace(regex,"$1"+base)
      if (newLoc != document.location.href) {
        document.location.replace(newLoc)
      }
    }
  }
}

Leave a comment