Skip to content

Commit 7c11e06

Browse files
authored
Fix false-positive Preact detection (#50)
1 parent d6bf90d commit 7c11e06

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

internal/stack/stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func detectJSLibs(r *Result, html string) {
324324
{"Livewire", []string{"livewire/livewire", " wire:"}},
325325
{"Next.js", []string{"__next_data__", "/_next/"}},
326326
{"Nuxt", []string{"__nuxt", "/_nuxt/"}},
327-
{"Preact", []string{"preact.min.js", "preact/"}},
327+
{"Preact", []string{"preact.min.js", "preact/hooks", "preact/compat", "/preact@"}},
328328
{"React", []string{"react.production.min.js", "react-dom", "data-reactroot", "_reactlistening"}},
329329
{"Remix", []string{"__remix"}},
330330
{"Solid.js", []string{"solid-js", "_$createcomponent"}},

internal/stack/stack_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ func TestDetectJSLibs(t *testing.T) {
185185
html: `<script id="__next_data__" type="application/json">{"page":"/"}</script>`,
186186
want: []string{"Next.js"},
187187
},
188+
{
189+
name: "Preact from submodule import",
190+
html: `<script type="importmap">{"imports":{"preact/hooks":"https://esm.sh/preact/hooks"}}</script>`,
191+
want: []string{"Preact"},
192+
},
193+
{
194+
name: "Preact not detected from a tag URL",
195+
html: `<a href="/tags/preact/" class="tag">#Preact</a>`,
196+
want: nil,
197+
},
188198
{
189199
name: "no false positives",
190200
html: `<html><body><p>Just a simple page</p></body></html>`,

0 commit comments

Comments
 (0)