Skip to content

Instantly share code, notes, and snippets.

@xsthunder
Last active June 27, 2019 11:29
Show Gist options
  • Save xsthunder/fc1b790ea02f51888ece4012decd9a9f to your computer and use it in GitHub Desktop.
Save xsthunder/fc1b790ea02f51888ece4012decd9a9f to your computer and use it in GitHub Desktop.
// in main.js
import Router from 'vue-Router'
vue.use(Router)
const originalPush = router.push
router.push = function(obj, ...params){
const current = this.history.current
// console.log(this, current)
const currentPath = current.path
const prefix = "/simed/"
if(obj instanceof Object && obj['doNotHack'] !== true){
let toPath = obj['path']
if(toPath && currentPath.indexOf(prefix)==0 && toPath.indexOf(prefix) == -1){
toPath = `/simed${toPath}`
obj['path'] = toPath
}
}
originalPush.call(this, obj, ...params) // see https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/call
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment