Skip to content

Commit

Permalink
stricter content normalization for headings and whitespcae
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter committed Jun 27, 2017
1 parent 00be430 commit a3bd89d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/licensee/content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Licensee
module ContentHelper
DIGEST = Digest::SHA1
END_OF_TERMS_REGEX = /^\s*end of terms and conditions\s*$/i
HR_REGEX = /^\s*[=-]{4,}/
HR_REGEX = /^\s*[=\-\* ]{4,}/
ALT_TITLE_REGEX = {
'bsd-2-clause' => /bsd 2-clause( \"simplified\")? license/i,
'bsd-3-clause' => /bsd 3-clause( \"new\" or \"revised\")? license/i,
Expand Down
10 changes: 8 additions & 2 deletions spec/licensee/content_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ def initialize(content = nil)
let(:content) do
<<-EOS.freeze.gsub(/^\s*/, '')
# The MIT License
=================
=================
Copyright 2016 Ben Balter
Copyright 2016 Ben Balter
*************************
The made
* * * *
up license.
-----------
EOS
Expand Down Expand Up @@ -73,10 +75,14 @@ def initialize(content = nil)

it 'strips HRs' do
expect(normalized_content).to_not match '---'
expect(normalized_content).to_not match '==='
expect(normalized_content).to_not include '***'
expect(normalized_content).to_not include '* *'
end

it 'squeezes whitespace' do
expect(normalized_content).to_not match ' '
expect(normalized_content).to_not match(/\t/)
end

it 'strips whitespace' do
Expand Down

0 comments on commit a3bd89d

Please sign in to comment.