diff --git a/src/juicy-redirect.html b/src/juicy-redirect.html
index ec3c07e..d67c39d 100755
--- a/src/juicy-redirect.html
+++ b/src/juicy-redirect.html
@@ -17,32 +17,29 @@
break;
}
};
- JuicyRedirectElementPrototype.redirect = function(newVal){
- var url;
- if(newVal == "current") {
+ JuicyRedirectElementPrototype.redirect = function(url){
+ if(!url){
+ return false;
+ }
+ if(url == "current") {
url = window.location.href;
}
- else {
- url = newVal;
+ if(this.hasAttribute("history")) {
+ history.pushState(null, null, url);
+ this.dispatchEvent(
+ new CustomEvent(
+ "juicy-redirect-pushstate",
+ {
+ "detail":{"url":url},
+ "bubbles": true
+ }
+ )
+ );
}
- if(url != "") {
- if(this.hasAttribute("history")) {
- history.pushState(null, null, url);
- this.dispatchEvent(
- new CustomEvent(
- "juicy-redirect-pushstate",
- {
- "detail":{"url":url},
- "bubbles": true
- }
- )
- );
- }
- else {
- window.location = url;
- }
- this.setAttribute("url", "");
+ else {
+ window.location = url;
}
+ this.setAttribute("url", "");
return url;
}