Skip to content

Commit 0de2189

Browse files
committed
Add guard condition for Podcast::TIMESTAMP_REGEX
1 parent 7c981bb commit 0de2189

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def convert_shownote(content)
4545
HTML
4646

4747
content.gsub!(/(#+) Shownote/) { shownote }
48-
content.gsub!(/-\s((\d:)?\d{1,}:\d{2})/) do
48+
return content unless content.match?(Podcast::TIMESTAMP_REGEX)
49+
50+
content.gsub!(Podcast::TIMESTAMP_REGEX) do
4951
t = $1
5052
t = (t.size == '0:00'.size) ? '0' + t : t
5153
t = (t.size == '00:00'.size) ? '00:' + t : t

app/models/podcast.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Podcast < ApplicationRecord
22
self.table_name = 'podcasts'
33
DIR_PATH = 'public/podcasts'
44
WDAY2JAPANESE = %w( )
5+
TIMESTAMP_REGEX = /-\s((\d:)?\d{1,}:\d{2})/
56

67
validates :title, presence: true
78
validates :content_size, presence: true

0 commit comments

Comments
 (0)