Permalink
Browse files

Merge pull request #344 from cowbell/without_extension

fixed _nonHtml to work on pathname only (without query string), added test
  • Loading branch information...
2 parents 59673d8 + 9d409a6 commit 838ccc866e2c4886f0f2b444251091579f901802 @reed reed committed Feb 14, 2014
Showing with 33 additions and 2 deletions.
  1. +1 −2 lib/assets/javascripts/turbolinks.js.coffee
  2. +4 −0 test/config.ru
  3. +2 −0 test/index.html
  4. +26 −0 test/withoutextension
@@ -289,8 +289,7 @@ class Link extends ComponentUrl
(@href is current.href + '#')
_nonHtml: ->
- url = @withoutHash()
- url.match(/\.[a-z]+(\?.*)?$/g) and not url.match(new RegExp("\\.(?:#{Link.HTML_EXTENSIONS.join('|')})?(\\?.*)?$", 'g'))
+ @pathname.match(/\.[a-z]+$/g) and not @pathname.match(new RegExp("\\.(?:#{Link.HTML_EXTENSIONS.join('|')})?$", 'g'))
_optOut: ->
link = @link
View
@@ -15,6 +15,10 @@ map "/500" do
# throw Internal Server Error (500)
end
+map "/withoutextension" do
+ run Rack::File.new(File.join(Root, "test", "withoutextension"), "Content-Type" => "text/html")
+end
+
map "/" do
run Rack::Directory.new(File.join(Root, "test"))
end
View
@@ -22,6 +22,8 @@
<ul style="margin-top:200px;">
<li><a href="/other.html">Other page</a></li>
<li><a href="/other.html"><span>Wrapped link</span></a></li>
+ <li><a href="/withoutextension">Without extension</a></li>
+ <li><a href="/withoutextension?sort=user.name">Without extension with query params</a></li>
<li><a href="http://www.google.com/">Cross origin</a></li>
<li><a href="/other.html" onclick="if(!confirm('follow link?')) { return false}">Confirm Fire Order</a></li>
<li><a href="/reload.html"><span>New assets track </span></a></li>
View
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Home</title>
+ <script type="text/javascript" src="/js/turbolinks.js"></script>
+ <script type="text/javascript">
+ document.addEventListener("page:change", function() {
+ console.log("page changed");
+ });
+
+ document.addEventListener("page:update", function() {
+ console.log("page updated");
+ });
+
+ document.addEventListener("page:restore", function() {
+ console.log("page restored");
+ });
+ </script>
+</head>
+<body class="page-other">
+ <ul>
+ <li><a href="/index.html">Home</a></li>
+ </ul>
+</body>
+</html>

0 comments on commit 838ccc8

Please sign in to comment.