Better electron URL parsing

Former-commit-id: 687e9a5632b7238a4c803235275f799c78852537 [formerly 5e1a1df7daa9ba76cf16ed496aedfae87d02ab24]
Former-commit-id: c7b5904175e8c10d3288fb999d26a5f53d571a39
This commit is contained in:
Jaifroid 2019-08-02 16:40:39 +01:00
parent 3f2df9992c
commit 0ba92c211e

View File

@ -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'
});