From 8f5d5d2bcf1079bddb3850caca3b7597675d4905 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 18 Sep 2011 18:21:33 -0400 Subject: [PATCH] more robust tos js check --- app/assets/javascripts/cookie.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/cookie.js b/app/assets/javascripts/cookie.js index 952bf8647..1d5ffea0e 100644 --- a/app/assets/javascripts/cookie.js +++ b/app/assets/javascripts/cookie.js @@ -44,9 +44,15 @@ } Danbooru.Cookie.initialize = function() { - if (location.href.match(/^\/(comment|pool|note|post)/) && this.get("tos") != "1") { + var loc = location.href; + + if (loc.match(/^http/)) { + loc = loc.replace(/^https?:\/\/[^\/]+/, "") + } + + if (loc.match(/^\/(comment|pool|note|post)/) && this.get("tos") != "1") { // Setting location.pathname in Safari doesn't work, so manually extract the domain. - var domain = location.href.match(/^(http:\/\/[^\/]+)/)[0]; + var domain = location.href.match(/^(https?:\/\/[^\/]+)/)[0]; location.href = domain + "/static/terms_of_service?url=" + location.href; return; }