@@ -23,6 +23,7 @@ const serveIndex = require('serve-index');
2323const webpack = require ( 'webpack' ) ;
2424const webpackDevMiddleware = require ( 'webpack-dev-middleware' ) ;
2525const validateOptions = require ( 'schema-utils' ) ;
26+ const isAbsoluteUrl = require ( 'is-absolute-url' ) ;
2627const updateCompiler = require ( './utils/updateCompiler' ) ;
2728const createLogger = require ( './utils/createLogger' ) ;
2829const getCertificate = require ( './utils/getCertificate' ) ;
@@ -356,7 +357,7 @@ class Server {
356357 contentBase . forEach ( ( item ) => {
357358 this . app . get ( '*' , express . static ( item ) ) ;
358359 } ) ;
359- } else if ( / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) ) {
360+ } else if ( isAbsoluteUrl ( String ( contentBase ) ) ) {
360361 this . log . warn (
361362 'Using a URL as contentBase is deprecated and will be removed in the next major version. Please use the proxy option instead.'
362363 ) ;
@@ -408,8 +409,8 @@ class Server {
408409 this . app . get ( '*' , serveIndex ( item ) ) ;
409410 } ) ;
410411 } else if (
411- ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) &&
412- typeof contentBase !== 'number'
412+ typeof contentBase !== 'number' &&
413+ ! isAbsoluteUrl ( String ( contentBase ) )
413414 ) {
414415 this . app . get ( '*' , serveIndex ( contentBase ) ) ;
415416 }
@@ -418,13 +419,13 @@ class Server {
418419 setupWatchStaticFeature ( ) {
419420 const contentBase = this . options . contentBase ;
420421
421- if (
422- / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) ||
423- typeof contentBase === 'number'
424- ) {
422+ if ( isAbsoluteUrl ( String ( contentBase ) ) || typeof contentBase === 'number' ) {
425423 throw new Error ( 'Watching remote files is not supported.' ) ;
426424 } else if ( Array . isArray ( contentBase ) ) {
427425 contentBase . forEach ( ( item ) => {
426+ if ( isAbsoluteUrl ( String ( item ) ) ) {
427+ throw new Error ( 'Watching remote files is not supported.' ) ;
428+ }
428429 this . _watch ( item ) ;
429430 } ) ;
430431 } else {
0 commit comments