소스 검색

removed obsolete code

Gildas 7 년 전
부모
커밋
d0697eea80
1개의 변경된 파일6개의 추가작업 그리고 9개의 파일을 삭제
  1. 6 9
      lib/single-file/single-file-browser.js

+ 6 - 9
lib/single-file/single-file-browser.js

@@ -104,11 +104,14 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
 			if (!contentType.includes("/")) {
 				contentType = null;
 			}
-			const charsetValue = matchContentType[1] && matchContentType[1].trim();
+			const charsetValue = matchContentType[1] && matchContentType[1].trim().toLowerCase();
 			if (charsetValue) {
 				const matchCharset = charsetValue.match(/^charset=(.*)/);
-				if (matchCharset) {
-					charset = docHelper.removeQuotes(matchCharset[1]);
+				if (matchCharset && matchCharset[1]) {
+					charset = docHelper.removeQuotes(matchCharset[1].trim());
+				}
+				if (!charset && options.charset) {
+					charset = options.charset.trim();
 				}
 			}
 		}
@@ -136,12 +139,6 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
 			if (resourceContent.status >= 400 || (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT))) {
 				return { data: "", resourceURL };
 			}
-			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 (!charset) {
 				charset = "utf-8";
 			}