Since the only variable that's an issue here is `data` I don't think a `#gsub` of the entire string is entirely necessary, something like this might work and will handle additional cases:

```ruby
def resource_link
  encoded_data = URI::encode(data)
  "#{current_host}/img/#{encoding}/#{encoded_data}.#{format}"
end
```