mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 12:19:46 -04:00
Better electron URL parsing
Former-commit-id: 687e9a5632b7238a4c803235275f799c78852537 [formerly 5e1a1df7daa9ba76cf16ed496aedfae87d02ab24] Former-commit-id: c7b5904175e8c10d3288fb999d26a5f53d571a39
This commit is contained in:
parent
3f2df9992c
commit
0ba92c211e
9
main.js
9
main.js
@ -83,17 +83,20 @@ function createWindow() {
|
||||
app.on('ready', () => {
|
||||
protocol.registerFileProtocol('app', (request, callback) => {
|
||||
//protocol.registerHttpProtocol('app', (request, callback) => {
|
||||
let url = request.url.replace(/^app:\/\/([./]*)(.*)$/, function(_p0, relPath, linkUrl) {
|
||||
const url = request.url.replace(/^app:\/\/([^?#]*?)([^?#\/\\]+)(?:[#?].*$|$)/, function(_p0, relPath, linkUrl) {
|
||||
// // @TODO: Complete routine to recognize relative links below (../)
|
||||
// let i = 0;
|
||||
// let parsedPath = relPath.replace(/\.\.\//g, function(p0) {
|
||||
// i++;
|
||||
// });
|
||||
console.log(relPath + '+' + linkUrl);
|
||||
console.log(relPath + '+' + linkUrl + '=>');
|
||||
return relPath + linkUrl;
|
||||
});
|
||||
//let returnPath = path.normalize(`${__dirname}/${url}`);
|
||||
let returnPath = __dirname + '/' + url;
|
||||
console.log(returnPath);
|
||||
callback({
|
||||
path: path.normalize(`${__dirname}/${url}`)
|
||||
path: returnPath
|
||||
// url: 'file://' + path.normalize(`${__dirname}/${url}`),
|
||||
// method: 'GET'
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user