From c3602934bc187fbd0a7c5f1fb81994bbdd1d248f Mon Sep 17 00:00:00 2001 From: Fokke Zandbergen Date: Sat, 19 Nov 2016 11:44:01 +0100 Subject: [PATCH] Preserve search and hash --- lib/jekyll-redirect-from/redirect_page.rb | 13 +++++++++++-- spec/jekyll_redirect_from/redirect_page_spec.rb | 10 +++++++--- spec/jekyll_redirect_from/redirector_spec.rb | 10 +++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/jekyll-redirect-from/redirect_page.rb b/lib/jekyll-redirect-from/redirect_page.rb index efbe19c..9662eff 100644 --- a/lib/jekyll-redirect-from/redirect_page.rb +++ b/lib/jekyll-redirect-from/redirect_page.rb @@ -31,10 +31,19 @@ def generate_redirect_content(item_url) Redirecting… - +

Redirecting…

Click here if you are not redirected. - + EOF end diff --git a/spec/jekyll_redirect_from/redirect_page_spec.rb b/spec/jekyll_redirect_from/redirect_page_spec.rb index 62deacd..d31016e 100644 --- a/spec/jekyll_redirect_from/redirect_page_spec.rb +++ b/spec/jekyll_redirect_from/redirect_page_spec.rb @@ -10,15 +10,19 @@ context "#generate_redirect_content" do it "sets the #content to the generated refresh page" do - expect(page_content).to eq("\n\n\nRedirecting…\n\n\n

Redirecting…

\nClick here if you are not redirected.\n\n\n") + expect(page_content).to eq("\n\n\nRedirecting…\n\n\n

Redirecting…

\nClick here if you are not redirected.\n\n\n") end it "contains the meta refresh tag" do - expect(page_content).to include("") + expect(page_content).to include("") + end + + it "contains the url" do + expect(page_content).to include("var url = 'http://jekyllrb.com/2014/01/03/moving-to-jekyll.md';") end it "contains JavaScript redirect" do - expect(page_content).to include("location=\"http://jekyllrb.com/2014/01/03/moving-to-jekyll.md\"") + expect(page_content).to include("location=url;") end it "contains canonical link in header" do diff --git a/spec/jekyll_redirect_from/redirector_spec.rb b/spec/jekyll_redirect_from/redirector_spec.rb index 428dcc1..63deb80 100644 --- a/spec/jekyll_redirect_from/redirector_spec.rb +++ b/spec/jekyll_redirect_from/redirector_spec.rb @@ -74,23 +74,23 @@ it "generates the refresh page for the collection with one redirect_to url" do expect(dest_dir("articles", "redirect-somewhere-else-plz.html")).to exist - expect(dest_dir("articles", "redirect-somewhere-else-plz.html").read).to include(%||) + expect(dest_dir("articles", "redirect-somewhere-else-plz.html").read).to include(%||) end it "generates the refresh page for the collection with one redirect_to url and a permalink" do expect(dest_dir("tags", "our projects", "index")).not_to exist expect(dest_dir("tags", "our projects", "index.html")).to exist - expect(dest_dir("tags", "our projects", "index.html").read).to include(%||) + expect(dest_dir("tags", "our projects", "index.html").read).to include(%||) end it "generates the refresh page for the page with one redirect_to url" do expect(dest_dir("one_redirect_to.html")).to exist - expect(dest_dir("one_redirect_to.html").read).to include(%||) + expect(dest_dir("one_redirect_to.html").read).to include(%||) end it "generates the refresh page for the page with multiple redirect_to urls" do expect(dest_dir("multiple_redirect_tos.html")).to exist - expect(dest_dir("multiple_redirect_tos.html").read).to include(%||) + expect(dest_dir("multiple_redirect_tos.html").read).to include(%||) end it "does not include any default layout" do @@ -101,7 +101,7 @@ it "generates the refresh page for the page with one redirect_to url and a permalink" do expect(dest_dir("tags", "how we work", "index")).not_to exist expect(dest_dir("tags", "how we work", "index.html")).to exist - expect(dest_dir("tags", "how we work", "index.html").read).to include(%||) + expect(dest_dir("tags", "how we work", "index.html").read).to include(%||) end end