@@ -31,7 +31,7 @@ function escape(html){
31
31
}
32
32
33
33
// Based on connect.static(), but streamlined and with added code injecter
34
- function staticServer ( root , spa ) {
34
+ function staticServer ( root ) {
35
35
var isFile = false ;
36
36
try { // For supporting mounting files instead of just directories
37
37
isFile = fs . statSync ( root ) . isFile ( ) ;
@@ -45,14 +45,6 @@ function staticServer(root, spa) {
45
45
var injectCandidates = [ new RegExp ( "</body>" , "i" ) , new RegExp ( "</svg>" ) ] ;
46
46
var injectTag = null ;
47
47
48
- // Single Page App - redirect handler
49
- if ( spa && req . url !== '/' ) {
50
- var route = req . url ;
51
- req . url = '/' ;
52
- res . statusCode = 302 ;
53
- res . setHeader ( 'Location' , req . url + '#' + route ) ;
54
- }
55
-
56
48
function directory ( ) {
57
49
var pathname = url . parse ( req . originalUrl ) . pathname ;
58
50
res . statusCode = 301 ;
@@ -146,10 +138,9 @@ LiveServer.start = function(options) {
146
138
LiveServer . logLevel = options . logLevel === undefined ? 2 : options . logLevel ;
147
139
var openPath = ( options . open === undefined || options . open === true ) ?
148
140
"" : ( ( options . open === null || options . open === false ) ? null : options . open ) ;
149
- var spa = options . spa || false ;
150
141
if ( options . noBrowser ) openPath = null ; // Backwards compatibility with 0.7.0
151
142
var file = options . file ;
152
- var staticServerHandler = staticServer ( root , spa ) ;
143
+ var staticServerHandler = staticServer ( root ) ;
153
144
var wait = options . wait === undefined ? 100 : options . wait ;
154
145
var browser = options . browser || null ;
155
146
var htpasswd = options . htpasswd || null ;
@@ -170,6 +161,9 @@ LiveServer.start = function(options) {
170
161
} else if ( LiveServer . logLevel > 2 ) {
171
162
app . use ( logger ( 'dev' ) ) ;
172
163
}
164
+ if ( options . spa ) {
165
+ middleware . push ( "spa" ) ;
166
+ }
173
167
// Add middleware
174
168
middleware . map ( function ( mw ) {
175
169
if ( typeof mw === "string" ) {
0 commit comments