-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove extra /
in feed ids.
#3026
Conversation
@@ -145,7 +145,7 @@ def _create_atom_id(resource_path, authority_name=None, date_string=None): | |||
# This is best we can do, and if the site_url is not set, then | |||
# this still results in an invalid feed. | |||
site_url = config.get('ckan.site_url', '') | |||
return '/'.join([site_url, resource_path]) | |||
return urlparse.urljoin(site_url, resource_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not quite right. We need to use url_for here so that the url is correctly built including site_url and root_path settings. This fix will only work for sites without a root_path setting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So then we do not pass resource_path
to this function anymore but pass some more data and create the actual path (or rather full url) in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds right. IIUC The intent of this code is to generate a url back to a feed controller method, so we should be able to use the parameters passed to that controller method and the name of the controller to call url_for to generate the correct url
@wardi it makes me wonder if the
And we would for example call it like this:
That would still make sure that the date string and authority are taken from the config if specified. |
An implementation of the behavior described above can be found here: https://github.com/ckan/ckan/compare/master...k-nut:3017-remove-double-slash-in-feed-ids?expand=1 |
As agreed in #3017 we decided that this should not be changed as it would create a new id for all datasets which is not desirable. |
Fixes #3017
Proposed fixes:
The
resource_path
that is passed to the_create_atom_id
function seems to always start with a/
. I did not want to manually strip that though because at some point the value passed here might be different. Fortunately theurlparse.urljoin
function removes duplicate slashes when joining urls so this should workThe test I added most certainly is not in the correct file (the other three are all touching the api while this is testing a private function) but I did not know where to put it.
Feedback on this is most welcome.
PS: I also marked that this is touching the api. Judging from the docstring the specification seems to be very strict about identifiers never changing. If we merge this change though the
ids
in the feed will change though (because they do not have the duplicate slash anymore). Not sure how to handle this.Features: