Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/229.canada.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prepends the requesting host and scheme to the `original_url` XLoader Resource field, supporting relative URIs for XLoader fields in the database.
10 changes: 5 additions & 5 deletions ckan/logic/action/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from flask import request
from urllib.parse import urlparse, urlunparse


import ckan
import ckan.lib.dictization
import ckan.logic as logic
Expand Down Expand Up @@ -1149,11 +1148,12 @@ def package_show(context: Context, data_dict: DataDict) -> ActionResult.PackageS
scheme=configured_parts.scheme)
current_domain = urlunparse(requesting_parts)
for res_dict in package_dict['resources']:
if(
res_dict.get('url_type') == 'upload' and
res_dict.get('url', '').startswith('/')
):
if res_dict.get('url_type') != 'upload':
continue
if res_dict.get('url', '').startswith('/'):
res_dict['url'] = current_domain + res_dict['url']
if res_dict.get('original_url', '').startswith('/'):
res_dict['original_url'] = current_domain + res_dict['original_url'] # XLoader field

return package_dict

Expand Down
Loading