Skip to content
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

Solves #31 #32

Merged
merged 2 commits into from
Sep 19, 2023
Merged

Solves #31 #32

merged 2 commits into from
Sep 19, 2023

Conversation

jbogdani
Copy link
Contributor

Fixes the missing slash dividing the base URL from the asset. The bug emerges when Directus is installed in a subdirectory.

@rijkvanzanten
Copy link
Member

Thanks @jbogdani! Does this create the opposite problem for people including the trailing slash? F.e. example.com/ turning into example.com//assets and/or example.com/test/ to example.com/test//assets

@jbogdani
Copy link
Contributor Author

jbogdani commented Sep 5, 2023

Hello,
I don't think so, because in l.176 the slash is being removed in the initialisation of basePath, if present:

const basePath = baseUrl.pathname.endsWith('/') ? baseUrl.pathname.slice(0, -1) : baseUrl.pathname;

@rijkvanzanten
Copy link
Member

That's just for the /graphql endpoint though 🤔 I think we might want to make the changed line (93) a bit smarter by making sure the final URL is correct. It might make more sense to use the URL() constructor there as well

@jbogdani
Copy link
Contributor Author

jbogdani commented Sep 6, 2023

Yes, you are right. I didn't notice that plugin.url is using baseUrl and not basePath that is already cleaned up.
What if we change l. 93 to something like:

const fileUrl = `${plugin.url}${plugin.url.endsWith('/') ? '' : '/'}assets/${file.id}`;

This is basically how basePath is defined in l.176.

If it makes sense to you I can update the patch.

@rijkvanzanten
Copy link
Member

Lets do that! Thanks @jbogdani 🙌🏻

@rijkvanzanten rijkvanzanten merged commit 742a5fb into directus:main Sep 19, 2023
1 check passed
@rijkvanzanten
Copy link
Member

This is released under 9.16.2

@jbogdani jbogdani deleted the patch-1 branch September 19, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants