Просмотр исходного кода

replaced occurences of "charSet" with "charset"

Gildas 7 лет назад
Родитель
Сommit
990dd7b674

+ 7 - 7
lib/single-file/frame-tree.js

@@ -212,25 +212,25 @@ this.frameTree = this.frameTree || (() => {
 		}
 		if (frameContent) {
 			const contentType = frameContent.headers && frameContent.headers.get("content-type");
-			let charSet, mimeType;
+			let charset, mimeType;
 			if (contentType) {
 				const matchContentType = contentType.toLowerCase().split(";");
 				mimeType = matchContentType[0].trim();
 				if (mimeType.indexOf("/") <= 0) {
 					mimeType = "text/html";
 				}
-				const charSetValue = matchContentType[1] && matchContentType[1].trim();
-				if (charSetValue) {
-					const matchCharSet = charSetValue.match(/^charset=(.*)/);
-					if (matchCharSet) {
-						charSet = docHelper.removeQuotes(matchCharSet[1]);
+				const charsetValue = matchContentType[1] && matchContentType[1].trim();
+				if (charsetValue) {
+					const matchCharset = charsetValue.match(/^charset=(.*)/);
+					if (matchCharset) {
+						charset = docHelper.removeQuotes(matchCharset[1]);
 					}
 				}
 			}
 			let doc;
 			try {
 				const buffer = await frameContent.arrayBuffer();
-				const content = (new TextDecoder(charSet)).decode(buffer);
+				const content = (new TextDecoder(charset)).decode(buffer);
 				const domParser = new DOMParser();
 				doc = domParser.parseFromString(content, mimeType);
 			} catch (error) {

+ 12 - 12
lib/single-file/single-file-browser.js

@@ -70,18 +70,18 @@ this.SingleFile = this.SingleFile || (() => {
 				return options && options.asDataURI ? "data:base64," : "";
 			}
 			let contentType = resourceContent.headers && resourceContent.headers.get("content-type");
-			let charSet;
+			let charset;
 			if (contentType) {
 				const matchContentType = contentType.toLowerCase().split(";");
 				contentType = matchContentType[0].trim();
 				if (contentType.indexOf("/") <= 0) {
 					contentType = null;
 				}
-				const charSetValue = matchContentType[1] && matchContentType[1].trim();
-				if (charSetValue) {
-					const matchCharSet = charSetValue.match(/^charset=(.*)/);
-					if (matchCharSet) {
-						charSet = docHelper.removeQuotes(matchCharSet[1]);
+				const charsetValue = matchContentType[1] && matchContentType[1].trim();
+				if (charsetValue) {
+					const matchCharset = charsetValue.match(/^charset=(.*)/);
+					if (matchCharset) {
+						charset = docHelper.removeQuotes(matchCharset[1]);
 					}
 				}
 			}
@@ -109,14 +109,14 @@ this.SingleFile = this.SingleFile || (() => {
 				if (resourceContent.status >= 400 || (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT))) {
 					return "";
 				}
-				if (!charSet) {
+				if (!charset) {
 					const matchCharset = contentType && contentType.match(/\s*;\s*charset\s*=\s*"?([^";]*)"?(;|$)/i);
-					if (matchCharset && matchCharset[1] || options.charSet) {
-						charSet = (matchCharset && matchCharset[1].toLowerCase()) || options.charSet;
+					if (matchCharset && matchCharset[1] || options.charset) {
+						charset = (matchCharset && matchCharset[1].toLowerCase()) || options.charset;
 					}
 				}
-				if (!charSet) {
-					charSet = "utf-8";
+				if (!charset) {
+					charset = "utf-8";
 				}
 				let buffer;
 				try {
@@ -131,7 +131,7 @@ this.SingleFile = this.SingleFile || (() => {
 					return "";
 				} else {
 					try {
-						return new TextDecoder(charSet).decode(buffer);
+						return new TextDecoder(charset).decode(buffer);
 					} catch (error) {
 						try {
 							return new TextDecoder("utf-8").decode(buffer);

+ 9 - 9
lib/single-file/single-file-core.js

@@ -549,13 +549,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		}
 
 		resetCharsetMeta() {
-			let charSet;
+			let charset;
 			this.doc.querySelectorAll("meta[charset], meta[http-equiv=\"content-type\"]").forEach(element => {
-				const charSetDeclaration = element.content.split(";")[1];
-				if (charSetDeclaration && !charSet) {
-					charSet = charSetDeclaration.split("=")[1];
-					if (charSet) {
-						this.charSet = charSet.trim().toLowerCase();
+				const charsetDeclaration = element.content.split(";")[1];
+				if (charsetDeclaration && !charset) {
+					charset = charsetDeclaration.split("=")[1];
+					if (charset) {
+						this.charset = charset.trim().toLowerCase();
 					}
 				}
 				element.remove();
@@ -771,7 +771,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 						mediaText = element.media;
 					}
 					this.stylesheets.set(element, { mediaText });
-					const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, url: this.options.url, charSet: this.charSet, compressCSS: this.options.compressCSS };
+					const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, url: this.options.url, charset: this.charset, compressCSS: this.options.compressCSS };
 					const isLinkTag = element.tagName.toLowerCase() == "link";
 					if (isLinkTag && element.rel.includes("alternate") && element.title) {
 						element.remove();
@@ -779,7 +779,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 						let stylesheetContent;
 						if (isLinkTag) {
 							if (element.charset) {
-								options.charSet = element.charset;
+								options.charset = element.charset;
 							}
 							stylesheetContent = await DomProcessorHelper.resolveLinkStylesheetURLs(element.href, this.baseURI, options);
 						} else {
@@ -1228,7 +1228,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		static async resolveLinkStylesheetURLs(resourceURL, baseURI, options) {
 			resourceURL = DomUtil.normalizeURL(resourceURL);
 			if (resourceURL && resourceURL != baseURI && resourceURL != ABOUT_BLANK_URI) {
-				const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, charSet: options.charSet };
+				const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, charset: options.charset };
 				let stylesheetContent = await Download.getContent(resourceURL, downloadOptions);
 				stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
 				if (options.compressCSS) {