detect-is-it-html-or-xhtml 5.0.5 → 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,59 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 5.0.5
4
+ * @version 5.0.6
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- var version$1 = "5.0.5";
10
+ var version$1 = "5.0.6";
11
11
 
12
12
  const version = version$1;
13
13
  function detectIsItHTMLOrXhtml(input) {
14
- function existy(x) {
15
- return x != null;
16
- }
17
- if (!input) {
18
- return null;
19
- }
20
- if (typeof input !== "string") {
21
- throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");
22
- }
23
- const metaTag = /<\s*!\s*doctype[^>]*>/im;
24
- const imgTag = /<\s*img[^>]*>/gi;
25
- const brTag = /<\s*br[^>]*>/gi;
26
- const hrTag = /<\s*hr[^>]*>/gi;
27
- const closingSlash = /\/\s*>/g;
28
- const extractedMetaTag = input.match(metaTag);
29
- if (extractedMetaTag) {
30
- const xhtmlRegex = /xhtml/gi;
31
- const svgRegex = /svg/gi;
32
- if (extractedMetaTag[0].match(xhtmlRegex) || extractedMetaTag[0].match(svgRegex)) {
33
- return "xhtml";
14
+ function existy(x) {
15
+ return x != null;
34
16
  }
35
- return "html";
36
- }
37
- const allImageTagsArr = input.match(imgTag) || [];
38
- const allBRTagsArr = input.match(brTag) || [];
39
- const allHRTagsArr = input.match(hrTag) || [];
40
- const allConcernedTagsArr = allImageTagsArr.concat(allBRTagsArr).concat(allHRTagsArr);
41
- if (allConcernedTagsArr.length === 0) {
42
- return null;
43
- }
44
- let slashCount = 0;
45
- for (let i = 0, len = allConcernedTagsArr.length; i < len; i++) {
46
- if (existy(allConcernedTagsArr[i].match(closingSlash))) {
47
- slashCount += 1;
17
+ if (!input) {
18
+ return null;
19
+ }
20
+ if (typeof input !== "string") {
21
+ throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");
22
+ }
23
+ const metaTag = /<\s*!\s*doctype[^>]*>/im;
24
+ const imgTag = /<\s*img[^>]*>/gi;
25
+ const brTag = /<\s*br[^>]*>/gi;
26
+ const hrTag = /<\s*hr[^>]*>/gi;
27
+ const closingSlash = /\/\s*>/g;
28
+ const extractedMetaTag = input.match(metaTag);
29
+ if (extractedMetaTag) {
30
+ const xhtmlRegex = /xhtml/gi;
31
+ const svgRegex = /svg/gi;
32
+ if (extractedMetaTag[0].match(xhtmlRegex) ||
33
+ extractedMetaTag[0].match(svgRegex)) {
34
+ return "xhtml";
35
+ }
36
+ return "html";
37
+ }
38
+ const allImageTagsArr = input.match(imgTag) || [];
39
+ const allBRTagsArr = input.match(brTag) || [];
40
+ const allHRTagsArr = input.match(hrTag) || [];
41
+ const allConcernedTagsArr = allImageTagsArr
42
+ .concat(allBRTagsArr)
43
+ .concat(allHRTagsArr);
44
+ if (allConcernedTagsArr.length === 0) {
45
+ return null;
48
46
  }
49
- }
50
- if (slashCount > allConcernedTagsArr.length / 2) {
51
- return "xhtml";
52
- }
53
- return "html";
47
+ let slashCount = 0;
48
+ for (let i = 0, len = allConcernedTagsArr.length; i < len; i++) {
49
+ if (existy(allConcernedTagsArr[i].match(closingSlash))) {
50
+ slashCount += 1;
51
+ }
52
+ }
53
+ if (slashCount > allConcernedTagsArr.length / 2) {
54
+ return "xhtml";
55
+ }
56
+ return "html";
54
57
  }
55
58
 
56
59
  export { detectIsItHTMLOrXhtml, version };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 5.0.5
4
+ * @version 5.0.6
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).detectIsItHtmlOrXhtml={})}(this,(function(t){"use strict";t.detectIsItHTMLOrXhtml=function(t){if(!t)return null;if("string"!=typeof t)throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");const e=/\/\s*>/g,n=t.match(/<\s*!\s*doctype[^>]*>/im);if(n){const t=/svg/gi;return n[0].match(/xhtml/gi)||n[0].match(t)?"xhtml":"html"}const i=t.match(/<\s*img[^>]*>/gi)||[],l=t.match(/<\s*br[^>]*>/gi)||[],o=t.match(/<\s*hr[^>]*>/gi)||[],r=i.concat(l).concat(o);if(0===r.length)return null;let s=0;for(let t=0,n=r.length;t<n;t++)null!=r[t].match(e)&&(s+=1);return s>r.length/2?"xhtml":"html"},t.version="5.0.5",Object.defineProperty(t,"__esModule",{value:!0})}));
10
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).detectIsItHtmlOrXhtml={})}(this,(function(t){"use strict";t.detectIsItHTMLOrXhtml=function(t){if(!t)return null;if("string"!=typeof t)throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");const e=/\/\s*>/g,n=t.match(/<\s*!\s*doctype[^>]*>/im);if(n){const t=/svg/gi;return n[0].match(/xhtml/gi)||n[0].match(t)?"xhtml":"html"}const i=t.match(/<\s*img[^>]*>/gi)||[],l=t.match(/<\s*br[^>]*>/gi)||[],o=t.match(/<\s*hr[^>]*>/gi)||[],r=i.concat(l).concat(o);if(0===r.length)return null;let s=0;for(let t=0,n=r.length;t<n;t++)null!=r[t].match(e)&&(s+=1);return s>r.length/2?"xhtml":"html"},t.version="5.0.6",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detect-is-it-html-or-xhtml",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "description": "Answers, is the string input string more an HTML or XHTML (or neither)",
5
5
  "keywords": [
6
6
  "check",
@@ -38,13 +38,12 @@
38
38
  "types": "types/index.d.ts",
39
39
  "scripts": {
40
40
  "build": "rollup -c",
41
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
42
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
41
+ "build:esbuild": "node '../../scripts/esbuild.js'",
42
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
43
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
43
44
  "clean_types": "../../scripts/cleanTypes.js",
44
45
  "dev": "rollup -c --dev",
45
46
  "devunittest": "npm run dev && tap --only -R 'base'",
46
- "esbuild": "node '../../scripts/esbuild.js'",
47
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
48
47
  "format": "npm run lect && npm run prettier && npm run lint",
49
48
  "lect": "lect",
50
49
  "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
@@ -53,17 +52,14 @@
53
52
  "republish": "npm publish || :",
54
53
  "tap": "tap",
55
54
  "pretest": "npm run build",
56
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
55
+ "test": "npm run test:ci && npm run perf",
56
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
57
57
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
58
58
  "tsc": "tsc",
59
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
59
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
60
60
  },
61
61
  "tap": {
62
62
  "check-coverage": false,
63
- "coverage-report": [
64
- "json-summary",
65
- "text"
66
- ],
67
63
  "node-arg": [
68
64
  "--no-warnings",
69
65
  "--experimental-loader",
@@ -83,7 +79,7 @@
83
79
  }
84
80
  },
85
81
  "dependencies": {
86
- "@babel/runtime": "^7.16.0"
82
+ "@babel/runtime": "^7.16.3"
87
83
  },
88
84
  "devDependencies": {
89
85
  "@babel/cli": "^7.16.0",
@@ -94,8 +90,8 @@
94
90
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
95
91
  "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
96
92
  "@babel/plugin-proposal-optional-chaining": "^7.16.0",
97
- "@babel/plugin-transform-runtime": "^7.16.0",
98
- "@babel/preset-env": "^7.16.0",
93
+ "@babel/plugin-transform-runtime": "^7.16.4",
94
+ "@babel/preset-env": "^7.16.4",
99
95
  "@babel/preset-typescript": "^7.16.0",
100
96
  "@babel/register": "^7.16.0",
101
97
  "@istanbuljs/esm-loader-hook": "^0.1.2",
@@ -105,25 +101,25 @@
105
101
  "@rollup/plugin-node-resolve": "^13.0.6",
106
102
  "@rollup/plugin-strip": "^2.1.0",
107
103
  "@rollup/plugin-typescript": "^8.3.0",
108
- "@types/node": "^16.11.6",
104
+ "@types/node": "^16.11.9",
109
105
  "@types/tap": "^15.0.5",
110
- "@typescript-eslint/eslint-plugin": "^5.3.0",
111
- "@typescript-eslint/parser": "^5.3.0",
106
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
107
+ "@typescript-eslint/parser": "^5.4.0",
112
108
  "core-js": "^3.19.1",
113
109
  "cross-env": "^7.0.3",
114
- "eslint": "^8.2.0",
115
- "lect": "^0.18.5",
116
- "rollup": "^2.59.0",
110
+ "eslint": "^8.3.0",
111
+ "lect": "^0.18.6",
112
+ "rollup": "^2.60.0",
117
113
  "rollup-plugin-ascii": "^0.0.3",
118
114
  "rollup-plugin-banner": "^0.2.1",
119
115
  "rollup-plugin-cleanup": "^3.2.1",
120
116
  "rollup-plugin-dts": "^4.0.1",
121
117
  "rollup-plugin-terser": "^7.0.2",
122
- "tap": "^15.0.10",
118
+ "tap": "^15.1.2",
123
119
  "tslib": "^2.3.1",
124
- "typescript": "^4.4.4"
120
+ "typescript": "^4.5.2"
125
121
  },
126
122
  "engines": {
127
- "node": ">=12"
123
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
128
124
  }
129
125
  }