Commit b110c350 authored by Seth Gilbert's avatar Seth Gilbert

added functionality to bl-selector with no extension and with hash and/or query.

parent 76b85f06
......@@ -66,13 +66,25 @@ document.addEventListener('DOMContentLoaded', function() {
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function replaceSelector(url, desiredSelector){
var parts=url.split("/");
var name = parts.pop(); if(!name){name=parts.pop();}
var bits = name.split(".");
var base = bits.shift();
var extension = bits.pop();
parts.push(base + "." + desiredSelector + (desiredSelector?".":"") + extension);
return parts.join("/");
var mainParts = url.split(/(?=[?#])/g);
var baseUrl = mainParts[0];
var parts= baseUrl.split("/");
var name = parts.pop();
if(!name){
name=parts.pop();
}
var bits = name.split(".");
var base = bits.shift();
var extension = bits.pop() || "html";
parts.push(base + "." + desiredSelector + (desiredSelector?".":"") + extension);
var fullPath = parts.join("/");
//add back the hash and query if they exist.
fullPath = fullPath + (mainParts[1] || "") + (mainParts[2] || "");
return fullPath;
}
window.BL.replaceSelector = replaceSelector;
......@@ -316,7 +328,3 @@ document.addEventListener('DOMContentLoaded', function() {
window.BL.loadLibrary();
}, false);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment