Skip to content

Commit

Permalink
FIX: relative path mutation wasn’t used
Browse files Browse the repository at this point in the history
Note: we might want to do

```ruby
@record[:image] =
"#{uri.scheme}://#{uri.host}/#{@record[:image][/(?!\/).*/]}"
```

To avoid getting
`https://us.battle.net//forums/static/images/social-thumbs/overwatch.png
` instead of
`https://us.battle.net/forums/static/images/social-thumbs/overwatch.png`
 (watch for the double /)

It will work with `//` so I'm not fixing it for now.
  • Loading branch information
jjaffeux committed Aug 7, 2017
1 parent 3bf3e49 commit 2c8f4c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/onebox/layout.rb
Expand Up @@ -20,7 +20,7 @@ def initialize(name, record, cache)
end

@md5 = Digest::MD5.new
@view = View.new(name, record)
@view = View.new(name, @record)
@template_name = "_layout"
@template_path = load_paths.last
end
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/onebox/layout_spec.rb
Expand Up @@ -69,5 +69,11 @@ def data
html = described_class.new("amazon", record, cache).to_html
expect(html).to include(%|"foo"|)
end

it "rewrites relative image path" do
record = { image: "/image.png", link: "https://discourse.org" }
klass = described_class.new("whitelistedgeneric", record, cache)
expect(klass.view.record[:image]).to include("https://discourse.org")
end
end
end

1 comment on commit 2c8f4c2

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/cant-onebox-overwatch-forums-topic/67066/7

Please sign in to comment.