detect-is-it-html-or-xhtml 5.0.2 → 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.
package/CHANGELOG.md CHANGED
@@ -3,12 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## 5.0.1 (2021-09-13)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
-
12
6
  ## 5.0.0 (2021-09-09)
13
7
 
14
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -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.2
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.2";
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.2
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.2",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.2",
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,9 +38,10 @@
38
38
  "types": "types/index.d.ts",
39
39
  "scripts": {
40
40
  "build": "rollup -c",
41
- "esbuild": "node '../../scripts/esbuild.js'",
42
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
43
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
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",
44
+ "clean_types": "../../scripts/cleanTypes.js",
44
45
  "dev": "rollup -c --dev",
45
46
  "devunittest": "npm run dev && tap --only -R 'base'",
46
47
  "format": "npm run lect && npm run prettier && npm run lint",
@@ -50,20 +51,15 @@
50
51
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
51
52
  "republish": "npm publish || :",
52
53
  "tap": "tap",
53
- "tsc": "tsc",
54
54
  "pretest": "npm run build",
55
- "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",
56
57
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
57
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
58
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
59
- "clean_types": "../../scripts/cleanTypes.js"
58
+ "tsc": "tsc",
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,47 +79,47 @@
83
79
  }
84
80
  },
85
81
  "dependencies": {
86
- "@babel/runtime": "^7.15.4"
82
+ "@babel/runtime": "^7.16.3"
87
83
  },
88
84
  "devDependencies": {
89
- "@babel/cli": "^7.15.4",
90
- "@babel/core": "^7.15.5",
91
- "@babel/node": "^7.15.4",
92
- "@babel/plugin-external-helpers": "^7.14.5",
93
- "@babel/plugin-proposal-class-properties": "^7.14.5",
94
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
95
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
96
- "@babel/plugin-proposal-optional-chaining": "^7.14.5",
97
- "@babel/plugin-transform-runtime": "^7.15.0",
98
- "@babel/preset-env": "^7.15.6",
99
- "@babel/preset-typescript": "^7.15.0",
100
- "@babel/register": "^7.15.3",
85
+ "@babel/cli": "^7.16.0",
86
+ "@babel/core": "^7.16.0",
87
+ "@babel/node": "^7.16.0",
88
+ "@babel/plugin-external-helpers": "^7.16.0",
89
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
90
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
91
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
92
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
93
+ "@babel/plugin-transform-runtime": "^7.16.4",
94
+ "@babel/preset-env": "^7.16.4",
95
+ "@babel/preset-typescript": "^7.16.0",
96
+ "@babel/register": "^7.16.0",
101
97
  "@istanbuljs/esm-loader-hook": "^0.1.2",
102
98
  "@rollup/plugin-babel": "^5.3.0",
103
- "@rollup/plugin-commonjs": "^20.0.0",
99
+ "@rollup/plugin-commonjs": "^21.0.1",
104
100
  "@rollup/plugin-json": "^4.1.0",
105
- "@rollup/plugin-node-resolve": "^13.0.4",
101
+ "@rollup/plugin-node-resolve": "^13.0.6",
106
102
  "@rollup/plugin-strip": "^2.1.0",
107
- "@rollup/plugin-typescript": "^8.2.5",
108
- "@types/node": "^16.9.1",
103
+ "@rollup/plugin-typescript": "^8.3.0",
104
+ "@types/node": "^16.11.9",
109
105
  "@types/tap": "^15.0.5",
110
- "@typescript-eslint/eslint-plugin": "^4.31.0",
111
- "@typescript-eslint/parser": "^4.31.0",
112
- "core-js": "^3.17.3",
106
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
107
+ "@typescript-eslint/parser": "^5.4.0",
108
+ "core-js": "^3.19.1",
113
109
  "cross-env": "^7.0.3",
114
- "eslint": "^7.32.0",
115
- "lect": "^0.18.2",
116
- "rollup": "^2.56.3",
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
- "rollup-plugin-dts": "^4.0.0",
116
+ "rollup-plugin-dts": "^4.0.1",
121
117
  "rollup-plugin-terser": "^7.0.2",
122
- "tap": "^15.0.9",
118
+ "tap": "^15.1.2",
123
119
  "tslib": "^2.3.1",
124
- "typescript": "^4.4.3"
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
  }