Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: prevent invalid url when router base is /
  • Loading branch information
Pooya Parsa committed Jun 4, 2017
1 parent 3b135cc commit f0fd863
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions modules/manifest/index.js
Expand Up @@ -6,7 +6,7 @@ const hash = require('hash-sum')
const fixUrl = url => url.replace(/(?!^)\/\//g, '/').replace(':/', '://')// // ~> /

module.exports = function nuxtManifest(options) {
const routerBase = this.options.router.base
const routerBase = this.options.router.base === '/' ? '' : this.options.router.base
const defaultName = options.name || this.options.manifest.name || process.env.npm_package_name
const defaultShortName = process.env.npm_package_name || defaultName

Expand All @@ -16,12 +16,12 @@ module.exports = function nuxtManifest(options) {
description: defaultName,
icons: [
{
src: fixUrl(`${routerBase}icon.png`),
src: fixUrl(`${routerBase}/icon.png`),
sizes: '512x512',
type: 'image/png'
}
],
start_url: routerBase,
start_url: fixUrl(`${routerBase}/`),
display: 'standalone',
background_color: '#ffffff',
theme_color: (this.options.loading && this.options.loading.color) || '#3f51b5',
Expand All @@ -34,7 +34,9 @@ module.exports = function nuxtManifest(options) {
const manifestFileName = `manifest.${hash(manifest)}.json`
const distDir = 'static'
const manifestFilePath = path.resolve(this.options.rootDir, distDir, manifestFileName)
console.log(manifestFilePath)

// Fix problem with now deployments which start script is running on a ro environment
// We need to somehow detect module is running in build or start mode
if (!fs.existsSync(manifestFilePath)) {
fs.ensureDirSync(path.resolve(this.options.rootDir, distDir))
fs.writeFileSync(manifestFilePath, JSON.stringify(manifest), 'utf8')
Expand Down
2 changes: 1 addition & 1 deletion modules/workbox/index.js
Expand Up @@ -12,7 +12,7 @@ module.exports = function nuxtWorkbox(options) {
}

const swFileName = 'sw.js'
const routerBase = this.options.router.base
const routerBase = this.options.router.base === '/' ? '' : this.options.router.base
const publicPath = isUrl(this.options.build.publicPath)
? this.options.build.publicPath
: fixUrl(routerBase + this.options.build.publicPath)
Expand Down

0 comments on commit f0fd863

Please sign in to comment.