From 5c9795958b08c233eb2c4afab8054d55c3a33d98 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 2 Mar 2012 14:52:18 -0800 Subject: Minor logic fixes for URL resolution in CSS --- js/document/html-document.js | 10 ++++++---- js/mediators/io-mediator.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/js/document/html-document.js b/js/document/html-document.js index 54647d65..a56a7e3c 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -511,12 +511,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { fileCouldDirUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl.split(cssUrl.split('/')[cssUrl.split('/').length-1])[0]).replace(/\/\//gi, '/')); + + //TODO: Fix regEx to have logic for all possible URLs strings (currently prefixing all url()) + prefixUrl = 'url('+fileCouldDirUrl; + tag.innerHTML = cssData.content.replace(/url\(/gi, prefixUrl); - //TODO: Fix regEx to have logic for all possible URLs strings - prefixUrl = '('+fileCouldDirUrl+'../'; - tag.innerHTML = cssData.content.replace(/\(\.\.\//gi, prefixUrl); - + //console.log(("http://hello.com, https://google.com").replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, 'hello')) + //console.log(tag.innerHTML); //Looping through DOM to insert style tag at location of link element query = this._templateDocument.html.querySelectorAll(['link']); diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 64210a02..0a851a4d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -338,7 +338,7 @@ exports.IoMediator = Montage.create(Component, { // regex = new RegExp(fileCouldDirUrl.replace(/\//gi, '\\\/'), 'gi'); // - if (local.split('/').length > 1) { + if (local.split('/').length > 2) { adjCss = adjCss.replace(regex, '../'); } else { adjCss = adjCss.replace(regex, ''); -- cgit v1.2.3