From 8fca67d6d0fffb119a9491174a6866c90f0df168 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sat, 19 Apr 2025 13:05:21 -0700 Subject: [PATCH] fix static route ordering --- lib/dingus.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/dingus.js b/lib/dingus.js index 08ebe86..9ee9cf8 100644 --- a/lib/dingus.js +++ b/lib/dingus.js @@ -120,15 +120,16 @@ class Dingus { throw new RangeError('staticRoute parameter should not have trailing slash'); } + // /static/ serves /static/index.html + // define before /static/:file else :file would match '' + this.on(['GET'], `${opt.staticRoute}/`, this.handlerGetStaticFile.bind(this), 'index.html'); + // /static/:file serves file this.on(['GET'], `${opt.staticRoute}/:file`, opt.staticRouteFileName, this.handlerGetStaticFile.bind(this)); // /static forwards to /static/ this.on(['GET'], opt.staticRoute, this.handlerRedirect.bind(this), `${this.proxyPrefix}${opt.staticRoute}/`); - // /static/ serves /static/index.html - this.on(['GET'], `${opt.staticRoute}/`, this.handlerGetStaticFile.bind(this), 'index.html'); - // /favicon.ico and /robots.txt serve from /static/ this.on(['GET'], '/favicon.ico', this.handlerGetStaticFile.bind(this), 'favicon.ico'); this.on(['GET'], '/robots.txt', this.handlerGetStaticFile.bind(this), 'robots.txt'); -- 2.49.0