s4d 0.2.1 → 0.2.3
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/LICENSE.md +1 -1
- package/dist/DevServer.d.ts +2 -2
- package/dist/DevServer.js +18 -6
- package/package.json +8 -8
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2024 Morris Brodersen <mb@morrisbrodersen.de>
|
|
1
|
+
Copyright 2024-2025 Morris Brodersen <mb@morrisbrodersen.de>
|
|
2
2
|
|
|
3
3
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
4
4
|
with or without fee is hereby granted, provided that the above copyright notice
|
package/dist/DevServer.d.ts
CHANGED
package/dist/DevServer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as http from 'http';
|
|
3
1
|
import mime from 'mime';
|
|
4
|
-
import * as
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as http from 'node:http';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
5
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
6
6
|
export class DevServer {
|
|
7
7
|
webroot;
|
|
@@ -227,12 +227,12 @@ export class DevServer {
|
|
|
227
227
|
|
|
228
228
|
// Hot reload stylesheets
|
|
229
229
|
document.querySelectorAll('link[rel=stylesheet]').forEach((el) => {
|
|
230
|
-
const href = el.getAttribute('href');
|
|
230
|
+
const href = untaintURL(el.getAttribute('href'));
|
|
231
231
|
|
|
232
232
|
if (endsWithURL(data.url, href)) {
|
|
233
233
|
reload = false;
|
|
234
234
|
|
|
235
|
-
el.setAttribute('href', href);
|
|
235
|
+
el.setAttribute('href', taintURL(href));
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
|
|
@@ -283,7 +283,19 @@ export class DevServer {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
function containsURL(candidate, target) {
|
|
286
|
-
return candidate.
|
|
286
|
+
return candidate.includes(target.replace(/^\\.?\\//, ''));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function taintURL(url) {
|
|
290
|
+
if (url.includes("?")) {
|
|
291
|
+
return url + '&t=' + Math.random();
|
|
292
|
+
} else {
|
|
293
|
+
return url + '?t=' + Math.random();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function untaintURL(url) {
|
|
298
|
+
return url.replace(/[?&]t=[\\d.]+/, '');
|
|
287
299
|
}`;
|
|
288
300
|
}
|
|
289
301
|
async stat(file) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "s4d",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Minimal web development server with live reload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"local",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
24
27
|
"exports": "./dist/index.js",
|
|
25
28
|
"bin": {
|
|
26
29
|
"s4d": "dist/bin.js"
|
|
27
30
|
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc --project tsconfig.build.json",
|
|
33
33
|
"format": "prettier --write .",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"ws": "^8.16.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@eslint/js": "^
|
|
44
|
+
"@eslint/js": "^10.0.1",
|
|
45
45
|
"@playwright/test": "^1.44.1",
|
|
46
46
|
"@types/eslint__js": "^8.42.3",
|
|
47
|
-
"@types/node": "^
|
|
47
|
+
"@types/node": "^24.12.2",
|
|
48
48
|
"@types/ws": "^8.5.10",
|
|
49
|
-
"eslint": "^
|
|
49
|
+
"eslint": "^10.2.0",
|
|
50
50
|
"prettier": "^3.3.1",
|
|
51
|
-
"typescript": "^
|
|
51
|
+
"typescript": "^6.0.2",
|
|
52
52
|
"typescript-eslint": "^8.2.0"
|
|
53
53
|
}
|
|
54
54
|
}
|