Skip to content

Commit

Permalink
Merge pull request #268 from enriclluelles/feature/remove-addressable…
Browse files Browse the repository at this point in the history
…-gem

Remove dependency on addressable gem
  • Loading branch information
tagliala authored Sep 1, 2022
2 parents 59553c6 + e7468c4 commit be3dc59
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 13.0.0 / unreleased

* [FEATURE] Replace Addressable gem with `URI::DEFAULT_PARSER` ([#268](https://github.com/enriclluelles/route_translator/pull/234))
* [ENHANCEMENT] Update development dependencies

## 12.1.0 / 2021-12-20

* [FEATURE] Add Rails 7.0 compatibility
Expand Down
1 change: 0 additions & 1 deletion lib/route_translator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'active_support'
require 'addressable/uri'

require 'route_translator/extensions'
require 'route_translator/translator'
Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/translator/path/segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def translate_resource(str, locale, scope)
def translate_string(str, locale, scope)
translated_resource = translate_resource(str, locale.to_s, scope)

Addressable::URI.normalize_component translated_resource
URI::DEFAULT_PARSER.escape translated_resource
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RouteTranslator
VERSION = '12.1.0'
VERSION = '13.0.0'
end
1 change: 0 additions & 1 deletion route_translator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'actionpack', '>= 5.2', '< 7.1'
spec.add_runtime_dependency 'activesupport', '>= 5.2', '< 7.1'
spec.add_runtime_dependency 'addressable', '~> 2.7'

spec.add_development_dependency 'appraisal', '~> 2.4'
spec.add_development_dependency 'byebug', '>= 10.0', '< 12'
Expand Down
8 changes: 4 additions & 4 deletions test/integration/host_locales_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_explicit_path

# native ru route on ru com
host! 'ru.testapp.com'
get Addressable::URI.normalize_component('/манекен')
get URI::DEFAULT_PARSER.escape('/манекен')
assert_equal 'ru', @response.body
assert_response :success
end
Expand All @@ -53,7 +53,7 @@ def test_generated_path
# native ru route on ru com
host! 'ru.testapp.com'
get '/native'
assert_equal Addressable::URI.normalize_component('/показывать'), @response.body
assert_equal URI::DEFAULT_PARSER.escape('/показывать'), @response.body
assert_response :success
end

Expand All @@ -79,7 +79,7 @@ def test_prefixed_path
def test_non_native_path
# ru route on es com
host! 'www.testapp.es'
get Addressable::URI.normalize_component('/ru/манекен')
get URI::DEFAULT_PARSER.escape('/ru/манекен')
assert_response :not_found

# es route on ru com
Expand All @@ -94,7 +94,7 @@ def test_non_native_path

# unprefixed ru route on es com
host! 'www.testapp.es'
get Addressable::URI.normalize_component('/манекен')
get URI::DEFAULT_PARSER.escape('/манекен')
assert_response :not_found
end
end
10 changes: 5 additions & 5 deletions test/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_utf8_characters
end
end

assert_routing Addressable::URI.normalize_component('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
assert_routing URI::DEFAULT_PARSER.escape('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
end

def test_resources_with_only
Expand Down Expand Up @@ -193,8 +193,8 @@ def test_namespaced_controllers

assert_routing '/gente/fans', controller: 'people/products', action: 'favourites', locale: 'es'
assert_routing '/favoritos', controller: 'products', action: 'favourites', locale: 'es'
assert_routing Addressable::URI.normalize_component('/ru/люди/кандидаты'), controller: 'people/products', action: 'favourites', locale: 'ru'
assert_routing Addressable::URI.normalize_component('/ru/избранное'), controller: 'products', action: 'favourites', locale: 'ru'
assert_routing URI::DEFAULT_PARSER.escape('/ru/люди/кандидаты'), controller: 'people/products', action: 'favourites', locale: 'ru'
assert_routing URI::DEFAULT_PARSER.escape('/ru/избранное'), controller: 'products', action: 'favourites', locale: 'ru'
end

def test_unnamed_root_route_without_prefix
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_config_available_locales
end
end

assert_routing Addressable::URI.normalize_component('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
assert_routing URI::DEFAULT_PARSER.escape('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
assert_routing '/people', controller: 'people', action: 'index', locale: 'en'
assert_unrecognized_route '/es/gente', controller: 'people', action: 'index', locale: 'es'
end
Expand All @@ -670,7 +670,7 @@ def test_config_available_locales_handles_strings
end
end

assert_routing Addressable::URI.normalize_component('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
assert_routing URI::DEFAULT_PARSER.escape('/ru/люди'), controller: 'people', action: 'index', locale: 'ru'
assert_routing '/people', controller: 'people', action: 'index', locale: 'en'
assert_unrecognized_route '/es/gente', controller: 'people', action: 'index', locale: 'es'
end
Expand Down

0 comments on commit be3dc59

Please sign in to comment.