oembed_proxy 0.2.6 → 0.3

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: e901566bc9fd0715903da004839a7c44802c9f389b5e67b5acc56e611cbf978d
4
- data.tar.gz: 6fd1ed2ce5cd3b1f4af6f952c0c9623d7f91602d3840cbe4f2c181a81ddb1441
3
+ metadata.gz: f604c0cdfb884bf07cf33db2c1cba4f3b3eb36a123cd2dcf795bee46bf2b17af
4
+ data.tar.gz: 66d599d359c6e28debd6adaf532008bed4cae542b51623aa6be78bf1e67f2f25
5
5
  SHA512:
6
- metadata.gz: d1fdc9982ef1b958774ca8771f1b9fe1c62e584b9539088b9226af21ef8c30a8711d4b0e9b8a2e4ca765c900e767403b8b812ad2a3116dbc29ea769563a1fee7
7
- data.tar.gz: d3da1c175fae6470645bf76de5cbbb340124d2522ae4935ed3daa17174f918657e2b4c0fe054079f7d8f7b3388daa6d2c0e7a54ac42777932065d26748a0adbd
6
+ metadata.gz: 4d6ca0159d8d1d4bc194b607cbd84d52cc42a753490f6d68c3ae4fbc4e16aef972407217f8e14310f5bfbce0cbcaff982166f8d993f8336ee604a76e2954da60
7
+ data.tar.gz: cb1d181ea1d5f04fbd97938c4ad592ac3d8f2e364f8ed9edc8914476810bf96db967c2c401de7ca933c518a602c58713ec96a8f55344ea903cfcb39da43f8cf5
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 2.7
3
3
  Exclude:
4
4
  - 'bin/*'
5
5
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # oEmbed Proxy Changelog
2
2
 
3
+ ## [`0.3`] (2023-08-24)
4
+
5
+ [`0.3`]: https://github.com/APMG/oembed_proxy/compare/v0.2.6...v0.3
6
+
7
+ * Update Spotify API URI
8
+ * Updated redirect handling to take more obscure types of redirects into account.
9
+
3
10
  ## [`0.2.6`] (2020-12-15)
4
11
 
5
12
  [`0.2.6`]: https://github.com/APMG/oembed_proxy/compare/v0.2.5...v0.2.6
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OembedProxy
2
2
 
3
- [![Build Status](https://travis-ci.org/APMG/oembed_proxy.svg?branch=master)](https://travis-ci.org/APMG/oembed_proxy)
3
+ [![Build Status](https://travis-ci.com/APMG/oembed_proxy.svg?branch=master)](https://app.travis-ci.com/github/APMG/oembed_proxy)
4
4
 
5
5
  Library to manage multiple oEmbed providers, including officially supported oEmbeds, custom implemented "fauxembeds", and Embed.ly providers.
6
6
 
@@ -66,8 +66,8 @@ module OembedProxy
66
66
  case res
67
67
  when Net::HTTPSuccess
68
68
  JSON[res.body]
69
- when Net::HTTPMovedPermanently, Net::HTTPFound
70
- fetch(URI(res['location']), times_recursed: (times_recursed + 1))
69
+ when Net::HTTPRedirection, Net::HTTPFound
70
+ fetch(redirect_location(uri, res['location']), times_recursed: (times_recursed + 1))
71
71
  else
72
72
  raise OembedException, (ERROR_CLASS_MAPPING[res.class] || "Unknown response: #{res.class}")
73
73
  end
@@ -75,6 +75,20 @@ module OembedProxy
75
75
  return nil # rubocop:disable Style/RedundantReturn
76
76
  end
77
77
 
78
+ def redirect_location(original_uri, new_location)
79
+ # Absolute URL
80
+ return URI(new_location) if new_location.start_with?('http')
81
+
82
+ # Relative path starting at root
83
+ return URI("#{original_uri.scheme}://#{original_uri.host}#{new_location}") if new_location.start_with?('/')
84
+
85
+ # Relative path starting at directory of original request (yuck)
86
+
87
+ base_path = Pathname.new(original_uri.path).parent.to_s # Get the current directory
88
+ base_path = '' if base_path == '/' # Special case, avoiding double slash in URL
89
+ URI("#{original_uri.scheme}://#{original_uri.host}#{base_path}/#{new_location}")
90
+ end
91
+
78
92
  def request_builder(uri)
79
93
  req = Net::HTTP::Get.new(uri)
80
94
  req['User-Agent'] = USER_AGENT
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OembedProxy
4
- VERSION = '0.2.6'
4
+ VERSION = '0.3'
5
5
  end
@@ -83,7 +83,7 @@ instagram:
83
83
  pattern_list: ["#\\Ahttps?://(?:www\\.)?instagr(?:\\.am|am\\.com)/p/.+#i"]
84
84
 
85
85
  spotify:
86
- endpoint: "https://embed.spotify.com/oembed/"
86
+ endpoint: "https://embed.spotify.com/oembed"
87
87
  pattern_list: ["#\\Ahttps?://(?:open|play)\\.spotify\\.com/.+#i"]
88
88
 
89
89
  audio-api:
data/oembed_proxy.gemspec CHANGED
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 2.0'
25
25
  spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
+
28
+ spec.required_ruby_version = '>= 2.7'
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oembed_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - APM Digital Products Group
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,8 +58,8 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.0'
61
- description:
62
- email:
61
+ description:
62
+ email:
63
63
  executables: []
64
64
  extensions: []
65
65
  extra_rdoc_files: []
@@ -99,7 +99,7 @@ homepage: https://github.com/APMG/oembed_proxy
99
99
  licenses:
100
100
  - MIT
101
101
  metadata: {}
102
- post_install_message:
102
+ post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
105
105
  - lib
@@ -107,15 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '2.7'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.0.3
118
- signing_key:
117
+ rubygems_version: 3.2.33
118
+ signing_key:
119
119
  specification_version: 4
120
120
  summary: Simple library to manage first party, embedly, and custom oembeds
121
121
  test_files: []