File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed
Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -2,20 +2,12 @@ import { defineHandler, HTTPError } from 'nitro/h3'
22import { downloadToBlob , parseUrl } from 'stackblitz-zip'
33
44export default defineHandler ( async ( event ) => {
5- if ( event . url . pathname === '/' )
6- return
7-
8- const path = event . context . params ! . path
9-
10- if ( ! path ) {
11- throw new HTTPError ( {
12- status : 400 ,
13- statusText : 'Missing path' ,
14- } )
15- }
5+ const { pathname } = event . url
6+ if ( pathname === '/' )
7+ return // render index.html
168
179 // Convert stackblitz.zip URL to stackblitz.com URL
18- const stackblitzUrl = `https://stackblitz.com/${ path . replace ( / \ .z i p $ / , '' ) } `
10+ const stackblitzUrl = `https://stackblitz.com/${ pathname . replace ( / ^ \/ | \ .z i p $ / g , '' ) } `
1911
2012 // Validate it's a valid StackBlitz edit URL
2113 if ( ! stackblitzUrl . match ( / s t a c k b l i t z \. c o m \/ e d i t \/ [ ^ / ? # ] + / ) ) {
You can’t perform that action at this time.
0 commit comments