File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
2339function 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
Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments