-
Notifications
You must be signed in to change notification settings - Fork 172
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
Conversion between local file paths and public file urls - consider scheme and port #4363
Comments
Something like this is doing the trick for me:
But I am unsure if this is the right approach, seems a bit overblown at the moment. Maybe there is an easier way. Would like to hear your feedback before maybe starting with a PR. |
@stefan-korn this is one of those things done a long long time ago when certain things were supposed to be able to work independently of Drupal. I think that's the reason we're using that "host" token thing instead of just "public://". If we just standardized on that I think we could eliminate a lot of this stuff, and maybe leverage something like https://www.drupal.org/project/convert_url_filter. In the meantime, if this is something that needs to be fixed soon I think something like this is fine, although I feel like there is probably an easier way to code this. Like just do a simple comparison of two arrays of URL parts rather than all this nested conditional logic. That's just an initial response though... if you move forward we can look at some options more in-depth. |
@dafeder : Thanks for the background infos. If we need a fix, we will probably patch it like shown above, but maybe we can also avoid the port differences in our setup altogether. Regarding convert_url_filter: The module is for use in text format filters? So you mean using the logic this module is using for DKAN rather than using the module itself? So it's about the Regex the module uses primarily? |
Current Behavior
The UrlHostTokenResolver converts a local file path to a public file URL via the hostify token. This gets the URL wrong if there is a difference in scheme or port between the URL that should be resolved (the url with the host TOKEN) and the public files url (that originates from the current request).
Partly this is related to resource_mapping entity which saves the hostified file path (for local files) in the file path field. This uses scheme and port that was used when creating the resource mapping.
Now, if for example you change the URL of the DKAN site in a way that affects either scheme or port, the links created from the host token do not work any more.
I am unsure if this is for some reason intented, but given the flexibility that Drupal itself offers regarding a change of the websites URL, this seems a bit limitating.
Expected Behavior
Local file resource should still be reachable if the DKAN site URL changes in port or scheme.
Steps To Reproduce
The problem gets more clear if you change the port instead of having two ports open.
Relevant log output (optional)
Anything else?
No response
The text was updated successfully, but these errors were encountered: