diff --git a/packages/atomic/src/components/common/interface/i18n.ts b/packages/atomic/src/components/common/interface/i18n.ts index 14a87bd3ccd..8a6825d1bdf 100644 --- a/packages/atomic/src/components/common/interface/i18n.ts +++ b/packages/atomic/src/components/common/interface/i18n.ts @@ -1,7 +1,7 @@ -import {getAssetPath} from '@stencil/core'; import DOMPurify from 'dompurify'; import Backend, {HttpBackendOptions} from 'i18next-http-backend'; import availableLocales from '../../../generated/availableLocales.json'; +import {getAssetPath} from '../../../utils/utils'; import {AnyEngineType} from './bindings'; import {BaseAtomicInterface} from './interface-common'; diff --git a/packages/atomic/src/utils/utils.ts b/packages/atomic/src/utils/utils.ts index 725baf4d2b2..e0521c43a7a 100644 --- a/packages/atomic/src/utils/utils.ts +++ b/packages/atomic/src/utils/utils.ts @@ -1,5 +1,3 @@ -import {getAssetPath} from '@stencil/core'; -import {NODE_TYPES} from '@stencil/core/mock-doc'; import DOMPurify from 'dompurify'; /** @@ -57,11 +55,11 @@ export function parseHTML(string: string) { } export function isElementNode(node: Node): node is Element { - return node.nodeType === NODE_TYPES.ELEMENT_NODE; + return node.nodeType === Node.ELEMENT_NODE; } export function isTextNode(node: Node): node is Text { - return node.nodeType === NODE_TYPES.TEXT_NODE; + return node.nodeType === Node.TEXT_NODE; } export function isVisualNode(node: Node) { @@ -84,6 +82,12 @@ export function containsVisualElement(node: Node) { return false; } +export function getAssetPath(path: string): string { + const baseUrl = window.location.origin; + const assetUrl = new URL(path, baseUrl); + return assetUrl.origin !== baseUrl ? assetUrl.href : assetUrl.pathname; +} + export function parseAssetURL(url: string, assetPath = './assets') { const [, protocol, remainder] = url.match(/^([a-z]+):\/\/(.*?)(\.svg)?$/) || [];