Skip to content

Commit 8b4cf22

Browse files
committed
chore: ignore internal HTTP detail
1 parent 9e276c3 commit 8b4cf22

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

app/error.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ const statusText = computed(() => {
2020
}
2121
})
2222
23+
// Sanitize error messages to hide internal details (e.g., HTTP methods, registry URLs)
24+
const sanitizedMessage = computed(() => {
25+
const msg = props.error.message
26+
if (!msg) return null
27+
28+
// Clean up messages that expose internal HTTP details like:
29+
// [GET] "https://registry.npmjs.org/...": 404 Not Found
30+
// Extract just the status part (e.g., "404 Not Found")
31+
const httpMatch = msg.match(/^\[(GET|POST|PUT|DELETE|PATCH)\]\s+"https?:\/\/[^"]+"\s*:\s*(.+)$/)
32+
if (httpMatch) {
33+
return httpMatch[2] // Return just "404 Not Found" part
34+
}
35+
36+
return msg
37+
})
38+
2339
function handleError() {
2440
clearError({ redirect: '/' })
2541
}
@@ -43,10 +59,10 @@ useHead({
4359
</h1>
4460

4561
<p
46-
v-if="error.message && error.message !== statusText"
62+
v-if="sanitizedMessage && sanitizedMessage !== statusText"
4763
class="text-fg-muted text-base max-w-md mb-8"
4864
>
49-
{{ error.message }}
65+
{{ sanitizedMessage }}
5066
</p>
5167

5268
<button

app/pages/package/[...package].vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,12 +1105,9 @@ defineOgImageComponent('Package', {
11051105
role="alert"
11061106
class="flex flex-col items-center py-20 text-center"
11071107
>
1108-
<h1 class="font-mono text-2xl font-medium mb-4">
1108+
<h1 class="font-mono text-2xl font-medium mb-8">
11091109
{{ $t('package.not_found') }}
11101110
</h1>
1111-
<p class="text-fg-muted mb-8">
1112-
{{ error?.message ?? $t('package.not_found_message') }}
1113-
</p>
11141111
<NuxtLink to="/" class="btn">{{ $t('common.go_back_home') }}</NuxtLink>
11151112
</div>
11161113
</main>

0 commit comments

Comments
 (0)