Navigation Menu

Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #344 from cowbell/without_extension
Browse files Browse the repository at this point in the history
fixed _nonHtml to work on pathname only (without query string), added test
  • Loading branch information
reed committed Feb 14, 2014
2 parents 59673d8 + 9d409a6 commit 838ccc8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/assets/javascripts/turbolinks.js.coffee
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/config.ru
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/index.html
Expand Up @@ -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>
Expand Down
26 changes: 26 additions & 0 deletions test/withoutextension
@@ -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.