Skip to content

Commit 18fdca5

Browse files
committed
refactor: unify escape-html to escape all 5 chars everywhere
1 parent 7311950 commit 18fdca5

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/stdlib/html/mod.nu

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# HTML DSL for nushell
22

3-
# Escape HTML special characters for text content
3+
# Escape HTML special characters
44
def escape-html []: string -> string {
5-
$in | str replace -a '&' '&amp;' | str replace -a '<' '&lt;' | str replace -a '>' '&gt;'
6-
}
7-
8-
# Escape HTML special characters for attribute values
9-
def escape-html-attr []: string -> string {
105
$in
116
| str replace -a '&' '&amp;'
127
| str replace -a '"' '&quot;'
@@ -47,7 +42,7 @@ export def attrs-to-string []: record -> string {
4742
} else {
4843
$attr.value
4944
}
50-
$'($attr.key)="($value | escape-html-attr)"'
45+
$'($attr.key)="($value | escape-html)"'
5146
}
5247
| where $it != ""
5348
| str join ' '

0 commit comments

Comments
 (0)