Browse Source

chore(gui-v2): add a workaround to avoid redirecting to `#/` on load

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3385/head
Pranav C 2 years ago
parent
commit
315de629ca
  1. 14
      packages/nc-gui-v2/scripts/updateNuxtRouting.js

14
packages/nc-gui-v2/scripts/updateNuxtRouting.js

@ -11,10 +11,16 @@ const filePath = path.join(__dirname, '..', 'node_modules', 'nuxt', 'dist', 'pag
const content = fs.readFileSync(filePath, 'utf8')
/** Replace `createWebHistory` with `createWebHashHistory` */
const updatedContent = content.replace(
/createRouter(\s*,\s*)createWebHistory(\s*,\s*)createMemoryHistory/,
`createRouter$1createWebHashHistory as createWebHistory$2createMemoryHistory`,
)
const updatedContent = content
.replace(
/createRouter(\s*,\s*)createWebHistory(\s*,\s*)createMemoryHistory/,
`createRouter$1createWebHashHistory as createWebHistory$2createMemoryHistory`,
)
/** Replace initial Handle initial routing based on hash path */
.replace(
`const { pathname, search, hash } = location;`,
`const { pathname, search, hash } = new URL((location.hash || '').replace(/^#/, ''), location.origin);`,
)
/** Update file content with updated code */
fs.writeFileSync(filePath, updatedContent, 'utf8')

Loading…
Cancel
Save