Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URI::escape deprecation #221

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: ruby
rvm:
- 2.7.0
- 2.6.1
- 2.5.1
- 2.4.1
Copy link
Member

Choose a reason for hiding this comment

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

2.4 reached EOL, I guess you can remove this one.

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## Unreleased
### Fixed
* Fixed a deprecation warning in Ruby 2.7.0 for `URI::escape` and replaced it with a backwards compatible mechanism. [#217](https://github.com/contentful/contentful.rb/issues/217)

## 2.15.2
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion contentful.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
gem.add_dependency 'multi_json', '~> 1'

gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rake', '< 11.0'
gem.add_development_dependency 'rake', '>= 12.3.3'
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'

gem.add_development_dependency 'guard'
Expand Down
7 changes: 6 additions & 1 deletion lib/contentful/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ def initialize(client, endpoint, query = {}, id = nil)

if id
@type = :single
@id = URI.escape(id)
# Given the deprecation of `URI::escape` and `URI::encode`
# it is needed to replace it with `URI::encode_www_form_component`.
# This method, does replace spaces with `+` instead of `%20`.
# Therefore, to keep backwards compatibility, we're replacing the resulting `+`
# back with `%20`.
@id = URI.encode_www_form_component(id).gsub('+', '%20')
else
@type = :multi
@id = nil
Expand Down