oembed_proxy 0.2.5 → 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: 63a465716cc2126538c5af5070e4cbc3b2bbae9ae0d5fbb5356e6755d8b900b8
4
- data.tar.gz: 9400774dd8bbf9b86ebdb6d2a614252654b797d3fa13598da4a605876fa87ec5
3
+ metadata.gz: f604c0cdfb884bf07cf33db2c1cba4f3b3eb36a123cd2dcf795bee46bf2b17af
4
+ data.tar.gz: 66d599d359c6e28debd6adaf532008bed4cae542b51623aa6be78bf1e67f2f25
5
5
  SHA512:
6
- metadata.gz: 100fe909ed6583855dd26cceef3930569332793fdd00f9afd789e3cbd0a8ae451949724bc844d23e70848f8c9ff526631be1d4ef72edb52b5ce1551a2380ca3b
7
- data.tar.gz: c7cb4ac5db8ca61535b685442340b03c61ac5eb80752e0979db68265cd8eb1ac5175709e6fa1fd2f5c6f66156fc43707c74fd43a8b42437d719da697fbad287d
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,18 @@
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
+
10
+ ## [`0.2.6`] (2020-12-15)
11
+
12
+ [`0.2.6`]: https://github.com/APMG/oembed_proxy/compare/v0.2.5...v0.2.6
13
+
14
+ * Add https to youtube and vimeo provider urls.
15
+
3
16
  ## [`0.2.5`] (2020-07-30)
4
17
 
5
18
  [`0.2.5`]: https://github.com/APMG/oembed_proxy/compare/v0.2.4...v0.2.5
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.5'
4
+ VERSION = '0.3'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  youtube:
2
- endpoint: "http://www.youtube.com/oembed"
2
+ endpoint: "https://www.youtube.com/oembed"
3
3
  pattern_list: ["#\\Ahttps?://(?:www\\.)?youtube\\.com/watch.+#i", "#\\Ahttps?://(?:www\\.)?youtube\\.com/playlist.+#i", "#\\Ahttps?://youtu\\.be/.+#i"]
4
4
 
5
5
  bliptv:
@@ -7,7 +7,7 @@ bliptv:
7
7
  pattern_list: ["#\\Ahttps?://blip\\.tv/.+#i"]
8
8
 
9
9
  vimeo:
10
- endpoint: "http://vimeo.com/api/oembed.json"
10
+ endpoint: "https://vimeo.com/api/oembed.json"
11
11
  pattern_list: ["#\\Ahttps?://(?:www\\.)?vimeo\\.com/.+#i"]
12
12
 
13
13
  dailymotion:
@@ -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.5
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - APM Digital Products Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-31 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
@@ -107,14 +107,14 @@ 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
117
+ rubygems_version: 3.2.33
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Simple library to manage first party, embedly, and custom oembeds