diff --git a/sveltejs/public/build/bundle.js b/sveltejs/public/build/bundle.js index ec94da1cc9c8ba37f4f428c77239e165d9d0b92f..a02e401a38171b2ce7c54a58b1c78de9f10f0d15 100644 Binary files a/sveltejs/public/build/bundle.js and b/sveltejs/public/build/bundle.js differ diff --git a/sveltejs/public/build/bundle.js.map b/sveltejs/public/build/bundle.js.map index b45b4630b052b9bfd62de5184e40fbb6f6629225..824e39092505c97f2c56c6852c77d3739ad2722c 100644 Binary files a/sveltejs/public/build/bundle.js.map and b/sveltejs/public/build/bundle.js.map differ diff --git a/sveltejs/src/App.svelte b/sveltejs/src/App.svelte index 005f3f6795a29832f0e1ead31620cd9b1323d054..591a3a407de56c38ececa6234b9ed03a0de50603 100644 --- a/sveltejs/src/App.svelte +++ b/sveltejs/src/App.svelte @@ -3,6 +3,7 @@ import ModulePage from './ModulePage.svelte'; import Loading from './Loading.svelte'; import { activeTab } from './stores'; + import { BASE_URL } from './constants'; const matches = window.location.pathname.match( /\/admin\/modules\/browse\/(.+)/, @@ -35,7 +36,7 @@ {#if !projectId} <ProjectBrowser /> {:else} - {#await load(Drupal.url(`drupal-org-proxy/project?id=${projectId}`))} + {#await load(`${BASE_URL}drupal-org-proxy/project?id=${projectId}`)} {#if loading} <Loading /> {/if} diff --git a/sveltejs/src/Filter.svelte b/sveltejs/src/Filter.svelte index a53a6e2b344c6b2e6202ad3d1c2d7b2de580de83..b77d70d839effca428df0edf701316500fbf0d01 100644 --- a/sveltejs/src/Filter.svelte +++ b/sveltejs/src/Filter.svelte @@ -6,6 +6,7 @@ activeTab, } from './stores'; import { normalizeOptions, shallowCompare } from './util'; + import { BASE_URL } from './constants'; const { Drupal } = window; const dispatch = createEventDispatcher(); @@ -124,7 +125,7 @@ } async function fetchAllCategories() { - const response = await fetch(Drupal.url('drupal-org-proxy/categories')); + const response = await fetch(`${BASE_URL}drupal-org-proxy/categories`); if (response.ok) { return response.json(); } diff --git a/sveltejs/src/ModulePage.svelte b/sveltejs/src/ModulePage.svelte index f16f242580e5335f58c81485502624dd4575bb2b..244cda18ebeba65c3d8824be020a15bd536253d6 100644 --- a/sveltejs/src/ModulePage.svelte +++ b/sveltejs/src/ModulePage.svelte @@ -6,6 +6,7 @@ import { moduleCategoryFilter, page } from './stores'; import ProjectIcon from './Project/ProjectIcon.svelte'; import { numberFormatter } from './util'; + import { BASE_URL } from './constants'; // eslint-disable-next-line import/no-mutable-exports,import/prefer-default-export export let project; @@ -14,7 +15,7 @@ function filterByCategory(id) { $moduleCategoryFilter = [id]; $page = 0; - window.location.href = Drupal.url('admin/modules/browse'); + window.location.href = `${BASE_URL}admin/modules/browse`; } onMount(() => { @@ -27,7 +28,7 @@ }); </script> -<a class="action-link" href={Drupal.url('admin/modules/browse')}> +<a class="action-link" href={`${BASE_URL}admin/modules/browse`}> <span aria-hidden="true">〈 </span> {Drupal.t('Back to Browsing')} </a> diff --git a/sveltejs/src/Project/ActionButton.svelte b/sveltejs/src/Project/ActionButton.svelte index 963f314c0cb4f5b86fd7d03e55191f5251e645a4..98e94f05ad743ae96990395b4190c697add43f7a 100644 --- a/sveltejs/src/Project/ActionButton.svelte +++ b/sveltejs/src/Project/ActionButton.svelte @@ -1,6 +1,6 @@ <script> import { onMount } from 'svelte'; - import { PACKAGE_MANAGER } from '../constants'; + import { BASE_URL, PACKAGE_MANAGER } from '../constants'; import Loading from '../Loading.svelte'; import { openPopup, getCommandsPopupMessage } from '../popup'; import AddInstallButton from './AddInstallButton.svelte'; @@ -32,9 +32,7 @@ * Return is not used, but is a promise due to this being async. */ const showStatus = async (initiate = false) => { - const url = Drupal.url( - `admin/modules/project_browser/install_in_progress/${project.id}`, - ); + const url = `${BASE_URL}admin/modules/project_browser/install_in_progress/${project.id}`; // /** diff --git a/sveltejs/src/Project/AddInstallButton.svelte b/sveltejs/src/Project/AddInstallButton.svelte index c5ab0edf1af9d20485a9f1d2ea0616d6502b047d..b18c5a444183a29b6d48de91d5681a1863ca0cab 100644 --- a/sveltejs/src/Project/AddInstallButton.svelte +++ b/sveltejs/src/Project/AddInstallButton.svelte @@ -1,6 +1,6 @@ <script> import { openPopup } from '../popup'; - import { PACKAGE_MANAGER } from '../constants'; + import { BASE_URL, PACKAGE_MANAGER } from '../constants'; import ProjectButtonBase from './ProjectButtonBase.svelte'; export let project; @@ -59,9 +59,7 @@ */ async function activateProject() { loading = true; - const url = Drupal.url( - `admin/modules/project_browser/activate/${project.id}`, - ); + const url = `${BASE_URL}admin/modules/project_browser/activate/${project.id}`; const installResponse = await fetch(url); if (!installResponse.ok) { handleError(installResponse); @@ -99,9 +97,7 @@ */ async function doRequests() { loading = true; - const beginInstallUrl = Drupal.url( - `admin/modules/project_browser/install-begin/${project.id}`, - ); + const beginInstallUrl = `${BASE_URL}admin/modules/project_browser/install-begin/${project.id}`; const beginInstallResponse = await fetch(beginInstallUrl); if (!beginInstallResponse.ok) { await handleError(beginInstallResponse); @@ -112,12 +108,10 @@ // with their own endpoint. When one stage completes, the next one is // requested. const installSteps = [ - Drupal.url( - `admin/modules/project_browser/install-require/${project.id}`, - ), - Drupal.url('admin/modules/project_browser/install-apply'), - Drupal.url('admin/modules/project_browser/install-post_apply'), - Drupal.url('admin/modules/project_browser/install-destroy'), + `${BASE_URL}admin/modules/project_browser/install-require/${project.id}`, + `${BASE_URL}admin/modules/project_browser/install-apply`, + `${BASE_URL}admin/modules/project_browser/install-post_apply`, + `${BASE_URL}admin/modules/project_browser/install-destroy`, ]; // eslint-disable-next-line no-restricted-syntax,guard-for-in diff --git a/sveltejs/src/Project/Project.svelte b/sveltejs/src/Project/Project.svelte index 79370b57450bb7dc2bd99f6ec2175eb6d6e12db4..6232328eb47636b8f45408c8ec46501a2c6d93da 100644 --- a/sveltejs/src/Project/Project.svelte +++ b/sveltejs/src/Project/Project.svelte @@ -7,7 +7,7 @@ import Categories from './Categories.svelte'; import ProjectIcon from './ProjectIcon.svelte'; import { focusedElement, mediaQueryValues } from '../stores'; - import { FULL_MODULE_PATH } from '../constants'; + import { BASE_URL, FULL_MODULE_PATH } from '../constants'; const { Drupal } = window; @@ -33,7 +33,7 @@ <a id="{project.project_machine_name}_title" class="pb-project__link" - href={Drupal.url(`admin/modules/browse/${project.id}`)} + href={`${BASE_URL}admin/modules/browse/${project.id}`} rel="noreferrer">{project.title}</a > </h3> diff --git a/sveltejs/src/ProjectBrowser.svelte b/sveltejs/src/ProjectBrowser.svelte index 8bf58aa2f575c2b59a300ba0885ea8631ec9b5e0..648f03c4136392d4c2915ae273d6cb2b2dd550e1 100644 --- a/sveltejs/src/ProjectBrowser.svelte +++ b/sveltejs/src/ProjectBrowser.svelte @@ -28,6 +28,7 @@ ALL_VALUES_ID, DEFAULT_SOURCE_ID, CURRENT_SOURCES_KEYS, + BASE_URL, FULL_MODULE_PATH, SORT_OPTIONS, ACTIVE_PLUGINS, @@ -102,9 +103,7 @@ ); } - const url = Drupal.url( - `drupal-org-proxy/project?${searchParams.toString()}`, - ); + const url = `${BASE_URL}drupal-org-proxy/project?${searchParams.toString()}`; const res = await fetch(url); if (res.ok) { diff --git a/sveltejs/src/constants.js b/sveltejs/src/constants.js index f2aace5f4b59e06c780ba00bef8292f43a06b3fc..c70fba462c5f55e49efaf2baeb8f9759d9e041a3 100644 --- a/sveltejs/src/constants.js +++ b/sveltejs/src/constants.js @@ -14,7 +14,8 @@ export const DEFAULT_SOURCE_ID = drupalSettings.project_browser.default_plugin_id; export const CURRENT_SOURCES_KEYS = drupalSettings.project_browser.current_sources_keys; -export const FULL_MODULE_PATH = Drupal.url(drupalSettings.project_browser.module_path); +export const BASE_URL = `${window.location.protocol}//${window.location.host}${drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix}`; +export const FULL_MODULE_PATH = `${BASE_URL}${drupalSettings.project_browser.module_path}`; export const DARK_COLOR_SCHEME = matchMedia('(forced-colors: active)').matches && matchMedia('(prefers-color-scheme: dark)').matches;