Skip to content

Commit

Permalink
remove look behind regex for safari
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan Gaikwad committed Sep 10, 2020
1 parent f772c8b commit 3632b01
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
12 changes: 8 additions & 4 deletions dist/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ module.exports = {
const FileManager = require('./FileManager');

const regexScript = new RegExp(/<script.*src.*=.*("|')(?!\w*(?:http|www)).*\.js('|").*<\/script>/, 'gi');
const regexScriptSrc = new RegExp(/(?<=src.*=.*('|"))(.*)(?=('|"))/, 'gi');
//const regexScriptSrc = new RegExp(/(?<=src.*=.*('|"))(.*)(?=('|"))/, 'gi');
const regexLink = new RegExp(/<link.*href.*=.*("|')(?!\w*(?:http|www)).*\.css('|")[^>]*>/, 'gi');
const regexLinkHref = new RegExp(/(?<=href.*=.*('|"))(.*)(?=('|"))/, 'gi');
//const regexLinkHref = new RegExp(/(?<=href.*=.*('|"))(.*)(?=('|"))/, 'gi');
const regexDir = new RegExp(/^(\.|\/)\/?/, 'g');

let activeIframeID = "";
Expand All @@ -140,7 +140,9 @@ module.exports = {
//extract JS files
let jsScripts = htmlCode.match(regexScript);
jsScripts.forEach(script => {
let srcUrl = script.match(regexScriptSrc)[0];
let tempElem = document.createElement('div');
tempElem.innerHTML = script;
let srcUrl = tempElem.firstChild.getAttribute('src');
let contents = this.getContents(srcUrl, htmlFileID);
if (contents) {
htmlCode = htmlCode.replace(script, `<script>${contents}</script>`);
Expand All @@ -152,7 +154,9 @@ module.exports = {

let linkFiles = htmlCode.match(regexLink);
linkFiles.forEach(link => {
let srcUrl = link.match(regexLinkHref)[0];
let tempElem = document.createElement('div');
tempElem.innerHTML = link;
let srcUrl = tempElem.firstChild.getAttribute('href');
let contents = this.getContents(srcUrl, htmlFileID);
if (contents) {
htmlCode = htmlCode.replace(link, `<style>${contents}</style>`);
Expand Down
2 changes: 1 addition & 1 deletion dist/js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/todo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- open html file in iframe
- create new file
- create new folder
- drag and resize
- open file from system
- open external file from url
- close project
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"deploy": "gh-pages -d dist",
"build": "webpack --progress",
"gulp": "gulp"
"gulp": "gulp",
"serve": "http-server dist"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 3632b01

Please sign in to comment.