Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jun 3, 2021
1 parent a1e59ee commit 6433303
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,22 @@ class Server {
setupHistoryApiFallbackFeature() {
const historyApiFallback = require('connect-history-api-fallback');

const fallback =
typeof this.options.historyApiFallback === 'object'
const options =
typeof this.options.historyApiFallback !== 'undefined'
? this.options.historyApiFallback
: null;
: {};

let logger;
if (fallback) {
// respect when user supplies their own logger
if (fallback.logger) {
logger = fallback.logger;
} else if (fallback.verbose) {
// enable logs using own logger when verbose is supplied
logger = this.logger.log;
}

if (typeof options.verbose === 'undefined') {
logger = this.logger.log.bind(
this.logger,
'[connect-history-api-fallback]'
);
}

// Fall back to /index.html if nothing else matches.
this.app.use(historyApiFallback({ ...fallback, logger }));
this.app.use(historyApiFallback({ logger, ...options }));
}

setupStaticFeature() {
Expand Down

0 comments on commit 6433303

Please sign in to comment.