Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 15 additions & 4 deletions src/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/sandbox/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ export function updateElementInfo <T> (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')
Expand Down