From 1559abff592b976e6b983881fe208da4257e98f7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 14 May 2012 10:44:42 -0700 Subject: Fixing webRequest URL parsing --- js/controllers/document-controller.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..e6b543d7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -95,11 +95,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (request) { //TODO: Check if frameId is proper if (this._hackRootFlag && request.parentFrameId !== -1) { - //TODO: Optimize creating string - //console.log(request); - //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); - //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/'))[1]}; + //Checking for proper URL redirect (from different directories) + if (request.url.indexOf('js/document/templates/banner') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; + } else if (request.url.indexOf('js/document/templates/html') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; + } else { + //Error, not a valid folder + } } } }, -- cgit v1.2.3