-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-links.js
More file actions
29 lines (21 loc) · 889 Bytes
/
fix-links.js
File metadata and controls
29 lines (21 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs').promises;
const path = require('path');
async function fixLinks() {
const frontendDir = './frontend';
const files = await fs.readdir(frontendDir);
for (const file of files) {
if (file.endsWith('.html')) {
const filePath = path.join(frontendDir, file);
let content = await fs.readFile(filePath, 'utf8');
// Replace hardcoded IP addresses with relative paths
content = content.replace(/http:\/\/192\.168\.4\.1\//g, '/');
content = content.replace(/http:\/\/192\.168\.4\.1/g, '');
content = content.replace(/192\.168\.4\.1\/menu/g, '/menu');
content = content.replace(/192\.168\.4\.1/g, 'window.location.host');
await fs.writeFile(filePath, content);
console.log(`✅ Fixed links in ${file}`);
}
}
console.log('🎉 All links fixed!');
}
fixLinks().catch(console.error);