Permalink
Browse files

Fix double slahs in url, not recognized by the internal router

  • Loading branch information...
1 parent 2b1e067 commit 6f2c32f80737622d64c0f58924d4279ba5f4cb88 @cdujeu cdujeu committed May 26, 2016
@@ -40,7 +40,7 @@ Class.create("BrowserOpener", AbstractEditor, {
if(url.substr(-1) == '/') url = url.substr(0, url.length - 1);
}
//var nonSecureAccessPath = window.ajxpServerAccessPath.substring(0, window.ajxpServerAccessPath.lastIndexOf('?'));
- var open_file_url = url + "/" + window.ajxpServerAccessPath + "&get_action=open_file&repository_id=" + repo + "&file=" + encodeURIComponent(node.getPath());
+ var open_file_url = LangUtils.trimRight(url, "\/") + "/" + window.ajxpServerAccessPath + "&get_action=open_file&repository_id=" + repo + "&file=" + encodeURIComponent(node.getPath());
if(this.editorOptions.context.__className == 'Modal'){
window.open(open_file_url);
@@ -53,7 +53,7 @@ Class.create("PDFJSViewer", AbstractEditor, {
// Get the direct PDF file link valid for this session.
var fileName = nodeOrNodes.getPath();
- var pdfurl = encodeURIComponent(url+'/'+ajxpBootstrap.parameters.get('ajxpServerAccess')+'&action=get_content&file=base64encoded:' + base64_encode(fileName) + '&fake_file_name=' + encodeURIComponent(PathUtils.getBasename(fileName)));
+ var pdfurl = encodeURIComponent(LangUtils.trimRight(url, '\/')+'/'+ajxpBootstrap.parameters.get('ajxpServerAccess')+'&action=get_content&file=base64encoded:' + base64_encode(fileName) + '&fake_file_name=' + encodeURIComponent(PathUtils.getBasename(fileName)));
// Hide the Pydio action bar.
this.element.down('.editor_action_bar').setStyle({display:'none'});
@@ -110,6 +110,7 @@ preload="auto" width="#{WIDTH}" height="#{HEIGHT}" data-setup="{}">\n\
url = document.location.origin + url;
}
}
+ url = LangUtils.trimRight(url, "\/");
var html5proxies = $H({});
var mime = ajxpNode.getAjxpMime();
@@ -143,6 +143,24 @@ class LangUtils{
return results;
}
+ static trimLeft(string, charlist) {
+ if (charlist === undefined) {
+ charlist = "\s";
+ }
+ return string.replace(new RegExp("^[" + charlist + "]+"), "");
+ };
+
+ static trimRight(string, charlist) {
+ if (charlist === undefined) {
+ charlist = "\s";
+ }
+ return string.replace(new RegExp("[" + charlist + "]+$"), "");
+ };
+
+ static trim(string, charlist){
+ return LangUtils.trimLeft(LangUtils.trimRight(string, charlist), charlist);
+ }
+
}
LangUtils.slugTable = [

0 comments on commit 6f2c32f

Please sign in to comment.