Skip to content

Commit

Permalink
text-data: Fix uri and path override
Browse files Browse the repository at this point in the history
Since `self.path` is also set in `Data#uri=`, there is no need to override it here.
Also, since converting a `URI` object to a string and replacing it does not
produce the expected result, we convert it to a `Pathname` object by replacing `path`.
  • Loading branch information
abetomo committed May 16, 2024
1 parent 1233245 commit e8ba0b4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/chupa-text/text-data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ module ChupaText
class TextData < Data
def initialize(text, options={})
super(options)
self.uri = uri.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
self.path = path.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
self.uri = Pathname(path.to_s.gsub(/\.[a-z\d]+\z/i, ".txt"))
self.mime_type = "text/plain"
self.body = text
self.size = text.bytesize
Expand Down

0 comments on commit e8ba0b4

Please sign in to comment.