@nerimity/html-embed 1.1.8 → 1.1.10

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwHA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;;;;IAEtC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8HA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;;;;IAEtC"}
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const allowedCssProperties = [
15
15
  "display",
16
16
  "position",
17
17
  "inset",
18
+ "background",
18
19
  "backgroundColor",
19
20
  "backgroundImage",
20
21
  "backgroundRepeat",
@@ -110,6 +111,11 @@ function h(tag, props, ...children) {
110
111
  throw new Error(unsafeCssProperty.split(":")[0].trim() + " property is not allowed!");
111
112
  }
112
113
  }
114
+ if (props === null || props === void 0 ? void 0 : props.href) {
115
+ if (!props.href.startsWith("http://") && !props.href.startsWith("https://")) {
116
+ throw new Error("href must start with http:// or https://");
117
+ }
118
+ }
113
119
  if (tag.toLowerCase() === "style" && children[0]) {
114
120
  checkCSS(children[0]);
115
121
  }
package/example.js CHANGED
@@ -6,12 +6,13 @@ const { htmlToJson } = require("./dist");
6
6
  console.log(htmlToJson(`
7
7
  <div class="owo">
8
8
  test
9
+ <a href="https:google.com">test</a>
9
10
  </div>
10
11
 
11
12
 
12
13
  <style>
13
14
  .owo {
14
- colorrrrr: red;
15
+ color: red;
15
16
  }
16
17
  </style>
17
18
  `))
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "name": "@nerimity/html-embed",
3
- "version": "1.1.8",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "build": "tsc",
8
- "example": "tsc & node example.js"
9
- },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC",
13
- "devDependencies": {
14
- "@types/css": "^0.0.37",
15
- "typescript": "^5.5.2"
16
- },
17
- "dependencies": {
18
- "css": "^3.0.0",
19
- "htm": "^3.1.0"
20
- }
21
- }
1
+ {
2
+ "name": "@nerimity/html-embed",
3
+ "version": "1.1.10",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "keywords": [],
7
+ "author": "",
8
+ "license": "ISC",
9
+ "devDependencies": {
10
+ "@types/css": "^0.0.37",
11
+ "typescript": "^5.5.2"
12
+ },
13
+ "dependencies": {
14
+ "css": "^3.0.0",
15
+ "htm": "^3.1.0"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "example": "tsc & node example.js"
20
+ }
21
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ const allowedCssProperties = [
11
11
  "display",
12
12
  "position",
13
13
  "inset",
14
+ "background",
14
15
  "backgroundColor",
15
16
  "backgroundImage",
16
17
  "backgroundRepeat",
@@ -107,6 +108,11 @@ function h(tag: string, props: any, ...children: any[]) {
107
108
  throw new Error(unsafeCssProperty.split(":")[0].trim() +" property is not allowed!")
108
109
  }
109
110
  }
111
+ if (props?.href) {
112
+ if (!props.href.startsWith("http://") && !props.href.startsWith("https://")) {
113
+ throw new Error("href must start with http:// or https://")
114
+ }
115
+ }
110
116
  if (tag.toLowerCase() === "style" && children[0]) {
111
117
  checkCSS(children[0]);
112
118
  }