HS fetch: 4→11/23 — POST options, Number format, route mock
Parser: fetch command consumes {method:"POST"}, with {opts}, and
handles as-format both before and after options.
Mock: Number format case-insensitive, /test route has number field.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -189,7 +189,7 @@ K.registerNative('load-library!',()=>false);
|
||||
let _testDeadline = 0;
|
||||
// Mock fetch routes
|
||||
const _fetchRoutes = {
|
||||
'/test': { status: 200, body: 'yay', json: '{"foo":1}', html: '<div>yay</div>' },
|
||||
'/test': { status: 200, body: 'yay', json: '{"foo":1}', html: '<div>yay</div>', number: '1.2' },
|
||||
'/test-json': { status: 200, body: '{"foo":1}', json: '{"foo":1}' },
|
||||
'/404': { status: 404, body: 'the body' },
|
||||
'/number': { status: 200, body: '1.2' },
|
||||
@@ -210,7 +210,7 @@ globalThis._driveAsync=function driveAsync(r,d){d=d||0;if(d>500||!r||!r.suspende
|
||||
if(fmt==='json'){try{doResume(JSON.parse(route.json||route.body||'{}'));}catch(e){doResume(null);}}
|
||||
else if(fmt==='html'){const frag=new El('fragment');frag.nodeType=11;frag.innerHTML=route.html||route.body||'';frag.textContent=frag.innerHTML.replace(/<[^>]*>/g,'');doResume(frag);}
|
||||
else if(fmt==='response')doResume({ok:(route.status||200)<400,status:route.status||200,url});
|
||||
else if(fmt==='Number'||fmt==='number')doResume(parseFloat(route.body||'0'));
|
||||
else if(fmt.toLowerCase()==='number')doResume(parseFloat(route.number||route.body||'0'));
|
||||
else doResume(route.body||'');
|
||||
}
|
||||
else if(opName==='io-parse-text'){const resp=items&&items[1];doResume(resp&&resp._body?resp._body:typeof resp==='string'?resp:'');}
|
||||
|
||||
Reference in New Issue
Block a user