Jelajahi Sumber

fixed issue with fragment-only urls

Former-commit-id: 752d40c69d95870fef17b73c8bacc87af6613afa
Gildas 6 tahun lalu
induk
melakukan
cf3c0e2819
1 mengubah file dengan 14 tambahan dan 10 penghapusan
  1. 14 10
      lib/single-file/single-file-core.js

+ 14 - 10
lib/single-file/single-file-core.js

@@ -1466,10 +1466,12 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				if (!Util.testIgnoredPath(resourceURL)) {
 					if (!resourceURL || Util.testValidPath(resourceURL)) {
 						let resolvedURL;
-						try {
-							resolvedURL = util.resolveURL(resourceURL, baseURI);
-						} catch (error) {
-							// ignored
+						if (!originalResourceURL.startsWith("#")) {
+							try {
+								resolvedURL = util.resolveURL(resourceURL, baseURI);
+							} catch (error) {
+								// ignored
+							}
 						}
 						if (Util.testValidURL(resolvedURL) && resourceURL != resolvedURL && stylesheetContent.includes(urlFunction)) {
 							stylesheetContent = stylesheetContent.replace(Util.getRegExp(urlFunction), originalResourceURL ? urlFunction.replace(originalResourceURL, resolvedURL) : "url(" + resolvedURL + ")");
@@ -1566,12 +1568,14 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 								let variableDefined;
 								const tokens = [];
 								findURLToken(originalResourceURL, declaration.value.children, (token, parent, rootFunction) => {
-									if (duplicate && options.groupDuplicateImages && rootFunction) {
-										const value = cssTree.parse("var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")", { context: "value" }).children.head;
-										tokens.push({ parent, token, value });
-										variableDefined = true;
-									} else {
-										token.data.value.value = content;
+									if (!originalResourceURL.startsWith("#")) {
+										if (duplicate && options.groupDuplicateImages && rootFunction) {
+											const value = cssTree.parse("var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")", { context: "value" }).children.head;
+											tokens.push({ parent, token, value });
+											variableDefined = true;
+										} else {
+											token.data.value.value = content;
+										}
 									}
 								});
 								if (variableDefined) {