qeweney 0.17 → 0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/qeweney/request_info.rb +16 -0
- data/lib/qeweney/version.rb +1 -1
- data/test/test_request_info.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70524001d652ee7b23a7a08b8c09aae2a7bf484148fa693b1c6b23a9c868ba51
|
4
|
+
data.tar.gz: 17c5254f9b07b242cc673219f2738bd6f4f0176bb4f076273b10f2aed9a21530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be74c2f1c96b8a4b4cd6b7e081f71b2c2019c2ab9c37b8680bdead5f4de1eddddca1522658ee56869837851bb6752fc147b3ffb42d0a49c4d7bd1f98822a0c98
|
7
|
+
data.tar.gz: 6f252321dc1f79d69e635d47ee34efefd1274a704122bfc736aa589618836d6e29e0cbb495669d1a96321569e75559c0a441ff0ebf91c71c4f38b2543383d27a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/qeweney/request_info.rb
CHANGED
@@ -34,6 +34,22 @@ module Qeweney
|
|
34
34
|
@scheme ||= @headers[':scheme']
|
35
35
|
end
|
36
36
|
|
37
|
+
# Rewrites the request path by replacing the given src with the given
|
38
|
+
# replacement.
|
39
|
+
#
|
40
|
+
# @param src [String, Regexp] src pattern
|
41
|
+
# @param replacement [String] replacement
|
42
|
+
# @return [Qeweney::Request] self
|
43
|
+
def rewrite!(src, replacement)
|
44
|
+
@headers[':path'] = @headers[':path']
|
45
|
+
.gsub(src, replacement)
|
46
|
+
.gsub('//', '/')
|
47
|
+
@path = nil
|
48
|
+
@uri = nil
|
49
|
+
@full_uri = nil
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
37
53
|
def uri
|
38
54
|
@uri ||= URI.parse(@headers[':path'] || '')
|
39
55
|
end
|
data/lib/qeweney/version.rb
CHANGED
data/test/test_request_info.rb
CHANGED
@@ -65,4 +65,26 @@ class RequestInfoTest < MiniTest::Test
|
|
65
65
|
'signin_ref' => '/'
|
66
66
|
}, r.cookies)
|
67
67
|
end
|
68
|
+
|
69
|
+
def test_rewrite!
|
70
|
+
r = Qeweney.mock(
|
71
|
+
':scheme' => 'https',
|
72
|
+
'host' => 'foo.bar',
|
73
|
+
':path' => '/hey/ho?a=b&c=d'
|
74
|
+
)
|
75
|
+
|
76
|
+
assert_equal '/hey/ho', r.path
|
77
|
+
assert_equal URI.parse('/hey/ho?a=b&c=d'), r.uri
|
78
|
+
assert_equal 'https://foo.bar/hey/ho?a=b&c=d', r.full_uri
|
79
|
+
|
80
|
+
r.rewrite!('/hhh', '/')
|
81
|
+
assert_equal '/hey/ho', r.path
|
82
|
+
assert_equal URI.parse('/hey/ho?a=b&c=d'), r.uri
|
83
|
+
assert_equal 'https://foo.bar/hey/ho?a=b&c=d', r.full_uri
|
84
|
+
|
85
|
+
r.rewrite!('/hey', '/')
|
86
|
+
assert_equal '/ho', r.path
|
87
|
+
assert_equal URI.parse('/ho?a=b&c=d'), r.uri
|
88
|
+
assert_equal 'https://foo.bar/ho?a=b&c=d', r.full_uri
|
89
|
+
end
|
68
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qeweney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|