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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES to `textbrowser`
2
2
 
3
+ ## 0.53.1
4
+
5
+ - fix: broken escaping of regex and dirname issue
6
+
3
7
  ## 0.53.0
4
8
 
5
9
  - fix: switch to serve-static to avoid headers problem
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textbrowser",
3
- "version": "0.53.0",
3
+ "version": "0.53.1",
4
4
  "description": "Multilinear text browser",
5
5
  "type": "module",
6
6
  "main": "dist/index-es.min.js",
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
- const fileServer = statik(import.meta.dirname);
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
  ))) {