no trailing slash

This commit is contained in:
Galen Wolfe-Pauly 2015-07-17 17:11:46 -07:00
parent 2f89f53e14
commit 4c841d651c
3 changed files with 23 additions and 8 deletions

View File

@ -37,8 +37,11 @@ module.exports = recl
dt = @ts - Number Date.now()
setPath: (href,hist) ->
if hist isnt false then history.pushState {}, "", window.tree.basepath href
next = href.split("#")[0]
href_parts = href.split("#")
next = href_parts[0]
if next.substr(-1) is "/" then next = next.slice(0,-1)
href_parts[0] = next
if hist isnt false then history.pushState {}, "", window.tree.basepath href_parts.join ""
rend = false
if next isnt @state.curr
React.unmountComponentAtNode $('#cont')[0]

View File

@ -24,7 +24,9 @@ $ ->
(window.location.pathname.replace window.tree._basepath, "").split("/")[0]
window.tree.basepath = (path) ->
if path[0] isnt "/" then path = "/"+path
window.tree._basepath + path
_path = window.tree._basepath + path
if _path.slice(-1) is "/" then _path = _path.slice(0,-1)
_path
window.tree.fragpath = (path) -> path.replace window.tree._basepath,""
window.tree.reactify = (obj) -> switch
# manx: {fork: ["string", {gn:"string" ga:{dict:"string"} c:{list:"manx"}}]}

View File

@ -122,11 +122,16 @@ module.exports = recl({
return dt = this.ts - Number(Date.now());
},
setPath: function(href, hist) {
var next, rend;
if (hist !== false) {
history.pushState({}, "", window.tree.basepath(href));
var href_parts, next, rend;
href_parts = href.split("#");
next = href_parts[0];
if (next.substr(-1) === "/") {
next = next.slice(0, -1);
}
href_parts[0] = next;
if (hist !== false) {
history.pushState({}, "", window.tree.basepath(href_parts.join("")));
}
next = href.split("#")[0];
rend = false;
if (next !== this.state.curr) {
React.unmountComponentAtNode($('#cont')[0]);
@ -667,10 +672,15 @@ $(function() {
window.tree._basepath = window.urb.util.basepath("/");
window.tree._basepath += (window.location.pathname.replace(window.tree._basepath, "")).split("/")[0];
window.tree.basepath = function(path) {
var _path;
if (path[0] !== "/") {
path = "/" + path;
}
return window.tree._basepath + path;
_path = window.tree._basepath + path;
if (_path.slice(-1) === "/") {
_path = _path.slice(0, -1);
}
return _path;
};
window.tree.fragpath = function(path) {
return path.replace(window.tree._basepath, "");