diff --git a/package.json b/package.json index 68a6cb43..253a9884 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@micro-zoe/micro-app", - "version": "1.0.0-rc.27", + "name": "bl-micro-app", + "version": "1.0.2", "description": "A lightweight, efficient and powerful micro front-end framework", "private": false, "main": "lib/index.min.js", @@ -48,11 +48,12 @@ "test:coverage": "jest --coverage", "test:unit": "jest src/__tests__/unit", "test:unit:coverage": "npm run test:unit -- --coverage", - "prepublishOnly": "yarn build" + "prepublishOnly": "yarn build", + "publish": "npm publish --access public" }, "repository": { "type": "git", - "url": "https://github.com/jd-opensource/micro-app.git" + "url": "https://github.com/kuaijing-bailing/micro-app.git" }, "publishConfig": { "access": "public" diff --git a/src/libs/utils.ts b/src/libs/utils.ts index d4dc48a9..bfaac3b7 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -313,13 +313,24 @@ export function formatAppURL(url: string | null, appName: string | null = null): if (!isString(url) || !url) return '' try { - const { origin, pathname, search } = createURL(addProtocol(url), (window.rawWindow || window).location.href) + const { origin, pathname, search, port, host, protocol} = createURL(addProtocol(url), (window.rawWindow || window).location.href) + + // 自定义协议时, origin 返回字符串 null + let newOrigin = origin; + if (origin == 'null') { + if (port) { + newOrigin = protocol + '//' + host + ':' + port + } else { + newOrigin = protocol + '//' + host + } + } + /** * keep the original url unchanged, such as .html .node .php .net .etc, search, except hash * BUG FIX: Never using '/' to complete url, refer to https://github.com/jd-opensource/micro-app/issues/1147 */ - const fullPath = `${origin}${pathname}${search}` - return /^https?:\/\//.test(fullPath) ? fullPath : '' + const fullPath = `${newOrigin}${pathname}${search}` + return /^\w+?:\/\//.test(fullPath) ? fullPath : '' } catch (e) { logError(e, appName) return '' @@ -366,7 +377,7 @@ export function getEffectivePath(url: string): string { export function CompletionPath(path: string, baseURI: string): string { if ( !path || - /^((((ht|f)tps?)|file):)?\/\//.test(path) || + /^((\w+):)?\/\//.test(path) || /^(data|blob):/.test(path) ) return path diff --git a/src/sandbox/adapter.ts b/src/sandbox/adapter.ts index 72938c57..b40489dd 100644 --- a/src/sandbox/adapter.ts +++ b/src/sandbox/adapter.ts @@ -157,7 +157,9 @@ export function updateElementInfo (node: T, appName: string | null): T { if (isAnchorElement(node)) { // a 标签 const microApp = AppManager.getInstance().get(appName) - if (microApp) { + const hrefDescriptor = Object.getOwnPropertyDescriptor(node, 'href') + const hrefConfigurable = hrefDescriptor?.configurable || !hrefDescriptor + if (microApp && hrefConfigurable) { props.href = { get() { return this.getAttribute('href')