diff --git a/packages/browser-vm/src/dynamicNode/processor.ts b/packages/browser-vm/src/dynamicNode/processor.ts index e2e8510d1..7b8f2a574 100644 --- a/packages/browser-vm/src/dynamicNode/processor.ts +++ b/packages/browser-vm/src/dynamicNode/processor.ts @@ -52,8 +52,16 @@ export class DynamicNodeProcessor { const src = el.getAttribute('src'); const href = el.getAttribute('href'); if (this.sandbox.options.fixStaticResourceBaseUrl) { - src && (el.src = transformUrl(baseUrl, src)); - href && (el.href = transformUrl(baseUrl, href)); + const transformUrlSrc = src && transformUrl(baseUrl, src); + const transformUrlHref = href && transformUrl(baseUrl, href); + // Consistent values do not need to be overwritten + if (transformUrlSrc !== src) { + el.src = transformUrlSrc; + } + + if (transformUrlHref !== href) { + el.href = transformUrlHref; + } } const url = el.src || el.href; diff --git a/packages/utils/src/utils.ts b/packages/utils/src/utils.ts index 6013066fb..9482ea32c 100644 --- a/packages/utils/src/utils.ts +++ b/packages/utils/src/utils.ts @@ -371,7 +371,11 @@ export function isAbsolute(url: string) { } export function transformUrl(resolvePath: string, curPath: string) { - if (curPath.startsWith('http') || curPath.startsWith('//')) { + if ( + curPath.startsWith('http') || + curPath.startsWith('//') || + curPath.startsWith('blob:') + ) { return curPath; } const baseUrl = new URL(resolvePath, location.href);