This program generates a cdn mappings using regex, it is built using javascript.
- it get's the html of the index folder
- it runs a regex pattern on it
const filesPattern =
/<a href="(?<path>.+?)">.+?<\/a>[ ]+(?<date>\d+-\w+-\d+ \d+:\d+)[ ]+(?<size>.+)/;
- it maps through the valid ones and modifies the groups to fit with the excepted result
- it maps through each folder to get it's children files/folders
[
{
"date": "2024-05-05T16:06:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/",
"type": "dir",
"name": "pk/",
"children": [
{
"date": "2024-05-05T16:06:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/test/",
"type": "dir",
"name": "test/",
"children": [
{
"date": "2024-05-05T16:07:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/test/test/",
"type": "dir",
"name": "test/",
"children": [
{
"date": "2024-05-05T16:06:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/test/test/test/",
"type": "dir",
"name": "test/",
"children": [
{
"date": "2024-05-05T16:06:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/test/test/test/test/",
"type": "dir",
"name": "test/",
"children": []
}
]
},
{
"date": "2024-05-05T16:06:00.000Z",
"size": 186,
"url": "http://localhost/Isos/pk/test/test/HTML%20File.html",
"type": "file",
"name": "HTML File.html"
}
]
},
{
"date": "2024-05-05T16:06:00.000Z",
"size": 186,
"url": "http://localhost/Isos/pk/test/HTML%20File.html",
"type": "file",
"name": "HTML File.html"
}
]
},
{
"date": "2024-05-05T16:06:00.000Z",
"size": 186,
"url": "http://localhost/Isos/pk/HTML%20File.html",
"type": "file",
"name": "HTML File.html"
},
{
"date": "2024-05-05T16:06:00.000Z",
"size": 0,
"url": "http://localhost/Isos/pk/LibreOffice%20Impress.odp",
"type": "file",
"name": "LibreOffice Impress.odp"
}
]
},
{
"date": "2024-04-08T17:49:00.000Z",
"size": 2344615936,
"url": "http://localhost/Isos/Bliss-v16.9.4-x86_64-OFFICIAL-gapps-20240220.iso",
"type": "file",
"name": "Bliss-v16.9.4-x86_64-OFFICIAL-gapps-20240220.iso"
},
{
"date": "2023-10-15T08:55:00.000Z",
"size": 658505728,
"url": "http://localhost/Isos/Debian%2012.2.0%20x64%20netinst.iso",
"type": "file",
"name": "Debian 12.2.0 x64 netinst.iso"
},
]