- Issue created by @Andrii_500
- πΊπΈUnited States chrisfromredfin Portland, Maine
In sveltejs/constants.js, we use "export const FULL_MODULE_PATH = `${BASE_URL}${drupalSettings.project_browser.module_path}`;" and FULL_MODULE_PATH is then used to get the path to the image.
BASE_URL uses "export const BASE_URL = `${window.location.protocol}//${window.location.host}${drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix}`;"
...does drupalSettings.path.pathPrefix include a language prefix?
Or, does the core moduleHandler do it?
`'module_path' => $this->moduleHandler->getModule('project_browser')->getPath(),`...I'm pretty sure it's probably drupalSettings.path.pathPrefix, which is meant for the "Drupal is installed in a subfolder" scenario; however, if it's a language prefix, that should NOT be included.
Does anyone know how core handles this kind of scenario, where it needs a path to the module without the language prefix?
This will need a test.
- πͺπΈSpain penyaskito Seville π, Spain πͺπΈ, UTC+2 πͺπΊ
In this page, using Spanish and no installing on the root,
drupalSettings.path
containsbaseUrl '/' pathPrefix 'es/' currentPath 'admin/modules/browse/drupalorg_jsonapi' currentPathIsAdmin true isFront false currentLanguage 'es'
I'm pretty sure we want
export const BASE_URL = `${window.location.protocol}//${window.location.host}${drupalSettings.path.baseUrl}`;
because that's the
BASE_URL
. The prefix might or not be there.Usually in core you can use
Drupal.url('/admin/content')
, and that resolves the proper base url and prefix to use.
I think we should replace most if not all usage ofBASE_URL
in the svelte app with that.For the issue at hand should be enough to ensure
FULL_MODULE_PATH
doesn't have the prefix. - @penyaskito opened merge request.
- πͺπΈSpain penyaskito Seville π, Spain πͺπΈ, UTC+2 πͺπΊ
Tests are green. Phpstan issues are not introduced here.
- πΊπΈUnited States chrisfromredfin Portland, Maine
This does fix the problem so I'm going to merge it now. But I think if we can rely on native Drupal api's like Drupal.url() we need to do that, so I'll open that as a follow-up.
-
chrisfromredfin β
committed 44a88e8c on 2.0.x authored by
penyaskito β
Issue #3517092 by penyaskito, andrii_500, chrisfromredfin, tim.plunkett...
-
chrisfromredfin β
committed 44a88e8c on 2.0.x authored by
penyaskito β
- πͺπΈSpain penyaskito Seville π, Spain πͺπΈ, UTC+2 πͺπΊ
I already did and have something in progress :-)
π Delete BASE_URL constant Active