nokogiri-html-ext 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aef0b60a4c542ff9bd3ee541ed06b42c6f758c9bfd8631c7fecccda288d01d5
4
- data.tar.gz: d0bbda1b35409f6c9297fdcd9811dc7387d69f8cc980d9484aaa21deae4e2410
3
+ metadata.gz: 63aafc92d00db444d3e8d3ec92817ef8246bd8dd7d66d7d3540d9aac2f55f96b
4
+ data.tar.gz: 904f44d50a9fb46c6383abb3e902c1a4166763778c1fe469696cff96c9d1c8a6
5
5
  SHA512:
6
- metadata.gz: c5d116103b9806d3b31d72b5d5caeeb806c077ac704d2a8d61a7fdefe8f819be1beea0f255912a642542a4a7fbbcc1ba80ef1c3e02309a439b8258700040279a
7
- data.tar.gz: 669115b6d27c9e217f2ed0f993c1cf61dc957e6850c42706de522afa964d7fe651d17b3805d1439e270a0e58b028abaacfc58ddd4f1d30520bd012005b7336c6
6
+ metadata.gz: 932fbeed6638155ec3033405ea43bf33f9b513e4e2b129ed62c8ef86b483e942ad894421de908e0a1077dd118383faf609b9da4c974a7a4c8a9ef2678ce3436e
7
+ data.tar.gz: 073d5a3983516d0bdfd68347ec42474d5c128cef1d7cf5170340d4eea24d334b10dbe5d39acd2fd5462ea1ac3da9b79031d2731db6ea5ad2c8b2fdadcba221b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.1 / 2022-08-20
4
+
5
+ - Handle escaped URLs and invalid URLs (af78837)
6
+ - Use ruby/debug gem instead of pry-byebug (4476b9d)
7
+
3
8
  ## v0.2.0 / 2022-07-02
4
9
 
5
10
  - Make `resolve_relative_url` method public (d132dd3)
@@ -69,13 +69,13 @@ module Nokogiri
69
69
  #
70
70
  # @return [String]
71
71
  def resolve_relative_url(url)
72
- url_str = url.to_s
73
-
74
- uri_parser.unescape(
75
- uri_parser.join(*[document.url.strip, base_href, url_str].compact.map { |u| uri_parser.escape(u) })
72
+ unescape(
73
+ uri_parser.join(*[document.url.strip, base_href, unescape(url)].compact.map { |u| escape(u) })
76
74
  .normalize
77
75
  .to_s
78
76
  )
77
+ rescue URI::InvalidComponentError, URI::InvalidURIError
78
+ unescape(url)
79
79
  end
80
80
 
81
81
  # Convert the document's relative URLs to absolute URLs.
@@ -99,6 +99,10 @@ module Nokogiri
99
99
 
100
100
  private
101
101
 
102
+ def escape(url)
103
+ uri_parser.escape(url.to_s)
104
+ end
105
+
102
106
  def resolve_relative_urls_for(attributes_map)
103
107
  attributes_map.each do |attribute, names|
104
108
  xpaths = names.map { |name| "//#{name}[@#{attribute}]" }
@@ -109,6 +113,10 @@ module Nokogiri
109
113
  end
110
114
  end
111
115
 
116
+ def unescape(url)
117
+ uri_parser.unescape(url.to_s)
118
+ end
119
+
112
120
  def uri_parser
113
121
  @uri_parser ||= URI::DEFAULT_PARSER
114
122
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nokogiri
4
4
  module HTMLExt
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-html-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-02 00:00:00.000000000 Z
11
+ date: 2022-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -44,7 +44,7 @@ licenses:
44
44
  - MIT
45
45
  metadata:
46
46
  bug_tracker_uri: https://github.com/jgarber623/nokogiri-html-ext/issues
47
- changelog_uri: https://github.com/jgarber623/nokogiri-html-ext/blob/v0.2.0/CHANGELOG.md
47
+ changelog_uri: https://github.com/jgarber623/nokogiri-html-ext/blob/v0.2.1/CHANGELOG.md
48
48
  rubygems_mfa_required: 'true'
49
49
  post_install_message:
50
50
  rdoc_options: []