linked_rails 0.0.4.pre.g7123943aa → 0.0.4.pre.g96885856b

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: 24aa1f95dca21df7152b6be6499f57d84a5fe37ac3944a0275b55d382a02f662
4
- data.tar.gz: 1cfe8deb84e11ec8ec5fa0f2b088a60fe3078f8abe07c2c12fb0fd0e210bed9c
3
+ metadata.gz: 91c75addc6ea759a73ff4fdce94549494d623fe819ee7ed0d2ea1557e7c2ac91
4
+ data.tar.gz: 4fcd4f439831e7aa196fa2fe610263949dfc316bb4566c9cb94562eb67e1c304
5
5
  SHA512:
6
- metadata.gz: 668e32f354c65baeafd91e3e4f5521bcef0c9b9194389afca075e0eb0b078e248e6ec3206df63799e0dbce29f7425e9b6c654e2847bfdba5f6a052476175868f
7
- data.tar.gz: 75835d167f14a03c94f24bf56fe8c13021ae2250b152637847cf0df295ddda9de827c0ae9a586ec6b1ac7fc8c2e7a62655e1bf00c1907a067a906a2e835b3f00
6
+ metadata.gz: ffcb80ce21ecbb28c0d42c79115b998bd859e689acbc4fcbb61ae6a494e75c09f3b906a466141412331fb5cc7076527fcf92fa227a58d00040db732d6123d350
7
+ data.tar.gz: e72f2247fa7ff7ca882e0644c69ed072e5ab93af8f02842f3495c3522e1fa300ce915703fcd297c21d36b1b658ccb7d0b3194aa4836fb7cf76afecec2e2bfeb0
@@ -98,6 +98,8 @@ module LinkedRails
98
98
  params = param.permit(:include, :iri)
99
99
  params[:iri] = URI(params[:iri])
100
100
  params
101
+ rescue URI::InvalidURIError
102
+ params.except(:iri)
101
103
  end
102
104
 
103
105
  def resource_response_body(iri, rack_body, status)
@@ -249,7 +251,7 @@ module LinkedRails
249
251
 
250
252
  def sanitized_relative_path(iri) # rubocop:disable Metrics/AbcSize
251
253
  iri.path = "#{iri.path}/" unless iri.path&.ends_with?('/')
252
- uri = URI(LinkedRails.iri.path.present? ? iri.to_s.split("#{LinkedRails.iri.path}/").last : iri)
254
+ uri = URI(LinkedRails.iri.path.chomp('/').present? ? iri.to_s.split("#{LinkedRails.iri.path}/").last : iri)
253
255
 
254
256
  [uri.path, uri.query].compact.join('?')
255
257
  end
@@ -187,7 +187,7 @@ module LinkedRails
187
187
 
188
188
  def target_url_fallback # rubocop:disable Metrics/AbcSize
189
189
  base = (resource.try(:singular_resource?) ? resource.singular_iri : resource.iri).dup
190
- base.path = "#{base.path}/#{target_path}" if target_path.present?
190
+ base.path = "#{base.path.chomp('/')}/#{target_path}" if target_path.present?
191
191
  base.query = Rack::Utils.parse_nested_query(base.query).merge(target_query).to_param if target_query.present?
192
192
  base
193
193
  end
@@ -41,7 +41,7 @@ module LinkedRails
41
41
  def blob_preview_iri
42
42
  return unless ActiveStorage::Blob.service.present?
43
43
 
44
- LinkedRails.iri(path: 'rails/active_storage/blobs/redirect/{signed_id}/preview')
44
+ "#{LinkedRails.iri(path: 'rails/active_storage/blobs/redirect')}/{signed_id}/preview')"
45
45
  end
46
46
 
47
47
  def blob_upload_iri
@@ -138,7 +138,7 @@ module LinkedRails
138
138
 
139
139
  def web_manifest_sw_section
140
140
  {
141
- src: "#{scope}/sw.js",
141
+ src: "#{scope.chomp('/')}/sw.js",
142
142
  scope: scope
143
143
  }
144
144
  end
@@ -38,7 +38,7 @@ module LinkedRails
38
38
  params = Rails.application.routes.recognize_path(iri.to_s, method: method)
39
39
 
40
40
  route_params_to_opts(params.merge(query), iri.to_s)
41
- rescue ActionController::RoutingError
41
+ rescue ActionController::RoutingError, SystemStackError
42
42
  EMPTY_IRI_OPTS.dup
43
43
  end
44
44
 
@@ -62,6 +62,7 @@ module LinkedRails
62
62
  iri = root_relative_iri.dup
63
63
  iri.scheme = LinkedRails.scheme
64
64
  iri.host = LinkedRails.host
65
+ iri.path = iri.path.presence || '/'
65
66
  iri
66
67
  end
67
68
 
data/lib/linked_rails.rb CHANGED
@@ -54,8 +54,10 @@ module LinkedRails
54
54
  @@scheme ||= Rails.application.routes.default_url_options[:protocol] || :http # rubocop:disable Style/ClassVars
55
55
  end
56
56
 
57
- def iri(**opts)
58
- RDF::URI.new(**{scheme: LinkedRails.scheme, host: LinkedRails.host}.merge(opts))
57
+ def iri(**args)
58
+ opts = {scheme: LinkedRails.scheme, host: LinkedRails.host}.merge(args)
59
+ opts[:path] = opts[:path].presence || '/'
60
+ RDF::URI.new(**opts)
59
61
  end
60
62
  end
61
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre.g7123943aa
4
+ version: 0.0.4.pre.g96885856b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Dingemans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_response