Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate output for paginate_path fix #8 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/jekyll-paginate/pager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def self.paginate_path(site, num_page)
return nil if num_page.nil?
return Pagination.first_page_url(site) if num_page <= 1
format = site.config['paginate_path']
unless /^\/*([[:word:]]+\/*)+[[:word:]]+\/*\-*:num/ =~ format
raise RuntimeError, 'paginate_path in config file is not valid'
end
format = format.sub(':num', num_page.to_s)
ensure_leading_slash(format)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/pager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
end
end

context "with specific characters in paginate_path" do
it "can't parse with colons" do
expect { build_site('paginate' => 2, 'paginate_path' => ':blog/page:num')}.to raise_error(RuntimeError, 'paginate_path in config file is not valid')
end
end

context "pagination disabled" do
let(:site) { build_site('paginate' => nil) }

Expand Down