Explorar o código

add {url-href-digest-sha-1} variable (see #812)

scruel %!s(int64=4) %!d(string=hai) anos
pai
achega
b68c82f514
Modificáronse 2 ficheiros con 6 adicións e 2 borrados
  1. 3 1
      extension/ui/pages/help.html
  2. 3 1
      lib/single-file/single-file-core.js

+ 3 - 1
extension/ui/pages/help.html

@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+ce                <!DOCTYPE html>
 <html>
 
 <head>
@@ -716,6 +716,8 @@
 					<li><code>{visit-seconds-locale}</code>: the localized value of the seconds (e.g. "31")</li>
 					<li><code>{url-href}</code>: the URL of the page (e.g. "http://example.com/category/index.html")
 					</li>
+					<li><code>{url-href-digest-sha-1}</code>: the SHA-1 hash value of the URL of the page (e.g.
+						4b826844d9f5c128533e4ff14d746334f3ac9e00)</li>
 					<li><code>{url-href-flat}</code>: the URL of the page with replaced slashes (e.g.
 						"http__example.com_category_index.html")</li>
 					<li><code>{url-pathname}</code>: the path name of the URL (e.g. "category/index.html")</li>

+ 3 - 1
lib/single-file/single-file-core.js

@@ -1485,7 +1485,9 @@ class ProcessorHelper {
 		template = await evalTemplateVariable(template, "url-hash", () => url.hash.substring(1) || "No hash", dontReplaceSlash, options.filenameReplacementCharacter);
 		template = await evalTemplateVariable(template, "url-host", () => url.host.replace(/\/$/, "") || "No host", dontReplaceSlash, options.filenameReplacementCharacter);
 		template = await evalTemplateVariable(template, "url-hostname", () => url.hostname.replace(/\/$/, "") || "No hostname", dontReplaceSlash, options.filenameReplacementCharacter);
-		template = await evalTemplateVariable(template, "url-href", () => decode(url.href) || "No href", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
+		const urlHref = decode(url.href);
+		template = await evalTemplateVariable(template, "url-href", () => urlHref || "No href", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
+		template = await evalTemplateVariable(template, "url-href-digest-sha-1", urlHref ? async () => util.digest("SHA-1", urlHref) : "No href", dontReplaceSlash, options.filenameReplacementCharacter);
 		template = await evalTemplateVariable(template, "url-href-flat", () => decode(url.href) || "No href", false, options.filenameReplacementCharacter);
 		template = await evalTemplateVariable(template, "url-referrer", () => decode(options.referrer) || "No referrer", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
 		template = await evalTemplateVariable(template, "url-referrer-flat", () => decode(options.referrer) || "No referrer", false, options.filenameReplacementCharacter);