File tree 4 files changed +15
-4
lines changed
4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " astro " : patch
3
+ ---
4
+
5
+ Fixes error overlay display on URI malformed error
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ export interface AstroErrorPayload {
111
111
hint ?: string ;
112
112
docslink ?: string ;
113
113
highlightedCode ?: string ;
114
- loc : {
114
+ loc ? : {
115
115
file ?: string ;
116
116
line ?: number ;
117
117
column ?: number ;
Original file line number Diff line number Diff line change @@ -631,7 +631,7 @@ class ErrorOverlay extends HTMLElement {
631
631
}
632
632
633
633
const code = this . root . querySelector < HTMLElement > ( '#code' ) ;
634
- if ( code && err . loc . file ) {
634
+ if ( code && err . loc ? .file ) {
635
635
code . style . display = 'block' ;
636
636
const codeHeader = code . querySelector < HTMLHeadingElement > ( '#code header' ) ;
637
637
const codeContent = code . querySelector < HTMLDivElement > ( '#code-content' ) ;
@@ -670,7 +670,7 @@ class ErrorOverlay extends HTMLElement {
670
670
}
671
671
672
672
// Add an empty line below the error line so we can show a caret under the error
673
- if ( err . loc . column ) {
673
+ if ( err . loc ? .column ) {
674
674
errorLine . insertAdjacentHTML (
675
675
'afterend' ,
676
676
`\n<span class="line error-caret"><span style="padding-left:${
Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ export function baseMiddleware(
20
20
return function devBaseMiddleware ( req , res , next ) {
21
21
const url = req . url ! ;
22
22
23
- const pathname = decodeURI ( new URL ( url , 'http://localhost' ) . pathname ) ;
23
+ let pathname : string ;
24
+ try {
25
+ pathname = decodeURI ( new URL ( url , 'http://localhost' ) . pathname ) ;
26
+ } catch ( e ) {
27
+ /* malform uri */
28
+ return next ( e ) ;
29
+ }
24
30
25
31
if ( pathname . startsWith ( devRoot ) ) {
26
32
req . url = url . replace ( devRoot , devRootReplacement ) ;
You can’t perform that action at this time.
0 commit comments