Skip to content

Commit 22620fd

Browse files
committed
Support paths using 2-byte characters
The following error occurs when the path contains 2-byte characters. ``` URI::InvalidURIError: URI must be ascii only "http://localhost:4567/\u732B" ``` Referring to the Capybara implementation, use Addressable instead of URI to support 2-byte characters. refs: https://github.com/teamcapybara/capybara/blob/3.40.0/lib/capybara/session.rb#L261
1 parent f46952e commit 22620fd

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

capybara-playwright.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
2525
spec.require_paths = ['lib']
2626

2727
spec.required_ruby_version = '>= 2.4'
28+
spec.add_dependency 'addressable'
2829
spec.add_dependency 'capybara'
2930
spec.add_dependency 'playwright-ruby-client', '>= 1.16.0'
3031
spec.add_development_dependency 'allure-rspec'

lib/capybara/playwright/browser.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'addressable/uri'
12
require_relative './tmpdir_owner'
23

34
module Capybara
@@ -74,9 +75,9 @@ def visit(path)
7475
assert_page_alive {
7576
url =
7677
if Capybara.app_host
77-
URI(Capybara.app_host).merge(path)
78+
Addressable::URI.parse(Capybara.app_host) + path
7879
elsif Capybara.default_host
79-
URI(Capybara.default_host).merge(path)
80+
Addressable::URI.parse(Capybara.default_host) + path
8081
else
8182
path
8283
end

spec/feature/assertion_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
sinatra.get '/finish.html' do
4040
'finish'
4141
end
42+
43+
sinatra.get '/猫' do
44+
'cat'
45+
end
4246
end
4347

4448
it 'survives against navigation' do
@@ -56,4 +60,10 @@
5660
refresh
5761
expect(page).to have_content('finish')
5862
end
63+
64+
it 'can access paths using 2-bytes characters' do
65+
visit '/猫'
66+
67+
expect(page).to have_content('cat')
68+
end
5969
end

0 commit comments

Comments
 (0)