diff --git a/lib/github_changelog_generator/reader.rb b/lib/github_changelog_generator/reader.rb index 6a3a75a9..f4827639 100644 --- a/lib/github_changelog_generator/reader.rb +++ b/lib/github_changelog_generator/reader.rb @@ -29,7 +29,7 @@ def initialize(options = {}) defaults = { heading_level: "##", heading_structures: [ - /^## \[(?.+?)\]\((?.+?)\)( \((?.+?)\))?$/, # rubocop:disable Lint/MixedRegexpCaptureTypes + /^## \[(?.+?)\](\((?.+?)\))?( \((?.+?)\))?$/, # rubocop:disable Lint/MixedRegexpCaptureTypes /^## (?.+?)( \((?.+?)\))?$/ # rubocop:disable Lint/MixedRegexpCaptureTypes ] } @@ -45,6 +45,8 @@ def initialize(options = {}) # The following heading structures are currently valid: # - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24) # - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) + # - ## [v1.0.2] (2015-03-24) + # - ## [v1.0.2] # - ## v1.0.2 (2015-03-24) # - ## v1.0.2 # diff --git a/spec/unit/reader_spec.rb b/spec/unit/reader_spec.rb index 23420fa2..199a0b64 100644 --- a/spec/unit/reader_spec.rb +++ b/spec/unit/reader_spec.rb @@ -38,6 +38,15 @@ it { is_expected.to include("url" => "https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10") } it { is_expected.to include("date" => "2015-03-18") } end + context "when given a named link" do + subject { @reader.parse_heading("## [1.3.10]") } + it { is_expected.to include("version" => "1.3.10") } + end + context "when given a named link with date" do + subject { @reader.parse_heading("## [1.3.10] (2015-03-18)") } + it { is_expected.to include("version" => "1.3.10") } + it { is_expected.to include("date" => "2015-03-18") } + end context "when no url and date is provided" do subject { @reader.parse_heading("## foobar") } it { is_expected.to include("version" => "foobar", "url" => nil, "date" => nil) }