textbrowser 0.53.0 → 0.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +4 -0
- package/package.json +1 -1
- package/server/main.js +9 -2
package/CHANGES.md
CHANGED
package/package.json
CHANGED
package/server/main.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
import http from 'node:http';
|
|
5
5
|
|
|
6
6
|
import statik from 'serve-static';
|
|
7
|
+
import {fileURLToPath} from 'url';
|
|
8
|
+
import {dirname} from 'path';
|
|
9
|
+
|
|
7
10
|
import fetch from 'node-fetch';
|
|
8
11
|
// @ts-expect-error Todo: Needs Types
|
|
9
12
|
import commandLineArgs from 'command-line-args';
|
|
@@ -196,7 +199,11 @@ let langData;
|
|
|
196
199
|
/** @type {Languages} */
|
|
197
200
|
let languagesInstance;
|
|
198
201
|
|
|
199
|
-
|
|
202
|
+
// `import.meta.dirname` not working on server despite hosting high enough
|
|
203
|
+
// version of Node and being `type: "module"`
|
|
204
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
205
|
+
const dir = dirname(__filename);
|
|
206
|
+
const fileServer = statik(import.meta.dirname ?? dir);
|
|
200
207
|
|
|
201
208
|
const srv = http.createServer(async (req, res) => {
|
|
202
209
|
// console.log('URL::', new URL(req.url));
|
|
@@ -239,7 +246,7 @@ const srv = http.createServer(async (req, res) => {
|
|
|
239
246
|
({regexp}) => {
|
|
240
247
|
// Hack to ignore middleware like jsonParser (and hopefully
|
|
241
248
|
// not get any other)
|
|
242
|
-
return regexp.source !== String.raw`^\/?(
|
|
249
|
+
return regexp.source !== String.raw`^\/?(?=\/|$)` &&
|
|
243
250
|
regexp.test(/** @type {string} */ (req.url));
|
|
244
251
|
}
|
|
245
252
|
))) {
|