mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Fix url starting with double slash
This commit is contained in:
parent
65eeff332e
commit
e8056f67eb
@ -11,6 +11,7 @@ import webpack from 'webpack'
|
||||
import serialize from 'serialize-javascript'
|
||||
import { createBundleRenderer } from 'vue-server-renderer'
|
||||
import { join, resolve, sep } from 'path'
|
||||
import { isUrl } from './utils'
|
||||
import clientWebpackConfig from './webpack/client.config.js'
|
||||
import serverWebpackConfig from './webpack/server.config.js'
|
||||
import chalk from 'chalk'
|
||||
@ -86,7 +87,7 @@ export function options () {
|
||||
if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders
|
||||
if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss
|
||||
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
|
||||
if (this.options.build.publicPath.indexOf('http') === 0 && this.dev) {
|
||||
if (this.dev && isUrl(this.options.build.publicPath)) {
|
||||
this.options.build.publicPath = defaults.publicPath
|
||||
}
|
||||
// Production, create server-renderer
|
||||
|
@ -7,7 +7,7 @@ import pify from 'pify'
|
||||
import pathToRegexp from 'path-to-regexp'
|
||||
import _ from 'lodash'
|
||||
import { resolve, join, dirname, sep } from 'path'
|
||||
import { promisifyRouteParams } from './utils'
|
||||
import { isUrl, promisifyRouteParams } from './utils'
|
||||
import { minify } from 'html-minifier'
|
||||
const copy = pify(fs.copy)
|
||||
const remove = pify(fs.remove)
|
||||
@ -29,7 +29,7 @@ export default function () {
|
||||
var srcStaticPath = resolve(this.srcDir, 'static')
|
||||
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
|
||||
var distPath = resolve(this.dir, this.options.generate.dir)
|
||||
var distNuxtPath = join(distPath, (this.options.build.publicPath.indexOf('http') === 0 ? '_nuxt' : this.options.build.publicPath))
|
||||
var distNuxtPath = join(distPath, (isUrl(this.options.build.publicPath) ? '_nuxt' : this.options.build.publicPath))
|
||||
return co(function * () {
|
||||
/*
|
||||
** Launch build process
|
||||
|
@ -31,6 +31,10 @@ export function urlJoin () {
|
||||
return [].slice.call(arguments).join('/').replace(/\/+/g, '/').replace(':/', '://')
|
||||
}
|
||||
|
||||
export function isUrl (url) {
|
||||
return (url.indexOf('http') === 0 || url.indexOf('//') === 0)
|
||||
}
|
||||
|
||||
export function promisifyRouteParams (fn) {
|
||||
// If routeParams[route] is an array
|
||||
if (Array.isArray(fn)) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
import vueLoaderConfig from './vue-loader.config'
|
||||
import { defaults } from 'lodash'
|
||||
import { join } from 'path'
|
||||
import { urlJoin } from '../utils'
|
||||
import { isUrl, urlJoin } from '../utils'
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -21,7 +21,7 @@ export default function ({ isClient, isServer }) {
|
||||
vendor: ['vue', 'vue-router', 'vue-meta']
|
||||
},
|
||||
output: {
|
||||
publicPath: (this.options.build.publicPath.indexOf('http') === 0 ? this.options.build.publicPath : urlJoin(this.options.router.base, this.options.build.publicPath))
|
||||
publicPath: (isUrl(this.options.build.publicPath) ? this.options.build.publicPath : urlJoin(this.options.router.base, this.options.build.publicPath))
|
||||
},
|
||||
performance: {
|
||||
hints: (this.dev ? false : 'warning')
|
||||
|
Loading…
Reference in New Issue
Block a user