Skip to content

Commit a8b4b95

Browse files
committed
🐛 Fix URINorm for Ruby 3+
1 parent 4fe7295 commit a8b4b95

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

.github/workflows/supported.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Supported Ruby Matrix
2+
3+
env:
4+
K_SOUP_COV_DO: false
5+
6+
on:
7+
push:
8+
branches:
9+
- 'master'
10+
tags:
11+
- '!*' # Do not execute on tags
12+
pull_request:
13+
branches:
14+
- '*'
15+
# Allow manually triggering the workflow.
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
# Cancels all previous workflow runs for the same branch that have not yet completed.
22+
concurrency:
23+
# The concurrency group contains the workflow name and the branch name.
24+
group: "${{ github.workflow }}-${{ github.ref }}"
25+
cancel-in-progress: true
26+
27+
jobs:
28+
test:
29+
name: Specs - Ruby ${{ matrix.ruby }}${{ matrix.name_extra || '' }}
30+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
31+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
include:
37+
- ruby: "3.3"
38+
rubygems: latest
39+
bundler: latest
40+
gemfile: vanilla
41+
- ruby: "3.2"
42+
rubygems: latest
43+
bundler: latest
44+
gemfile: vanilla
45+
#- Ruby 3.1 tests are run by coverage.yml
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
- name: Setup Ruby & RubyGems
50+
uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: "${{ matrix.ruby }}"
53+
rubygems: "${{ matrix.rubygems }}"
54+
bundler: "${{ matrix.bundler }}"
55+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56+
- name: Run tests
57+
run: bundle exec rake test

lib/openid/urinorm.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
module OpenID
44

55
module URINorm
6+
VALID_URI_SCHEMES = ['http','https'].freeze
67
public
78
def URINorm.urinorm(uri)
89
uri = URI.parse(uri)
910

1011
raise URI::InvalidURIError.new('no scheme') unless uri.scheme
12+
1113
uri.scheme = uri.scheme.downcase
12-
unless ['http','https'].member?(uri.scheme)
13-
raise URI::InvalidURIError.new('Not an HTTP or HTTPS URI')
14-
end
14+
raise URI::InvalidURIError.new('Not an HTTP or HTTPS URI') unless VALID_URI_SCHEMES.member?(uri.scheme)
15+
16+
raise URI::InvalidURIError.new('no host') if uri.host.nil? # For Ruby 2.7
17+
18+
raise URI::InvalidURIError.new('no host') if uri.host.empty? # For Ruby 3+
1519

16-
raise URI::InvalidURIError.new('no host') unless uri.host
1720
uri.host = uri.host.downcase
1821

1922
uri.path = remove_dot_segments(uri.path)

0 commit comments

Comments
 (0)