Skip to content

Commit

Permalink
fix handling when undefined value or contain escape string
Browse files Browse the repository at this point in the history
Finally!!🔥
  • Loading branch information
ihsangan committed Jun 8, 2024
1 parent 7b9ff88 commit ca3c7fd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,21 @@ async function serveResult(request) {
let dc = new URL(request.url).searchParams.get('decode')
let code = 200
let result = await callAPI(request)
if (result.name.includes(`undefined`)) {
if (result.name != undefined) {
result.name = result.name.replace(/\u002B/g, '%20')
if (dc == false) {
result = result
}
if (!dc || dc == true) {
result.name = decodeURIComponent(result.name)
}
}
else if (result.name = undefined) {
result = {success:false,message:"Not found"}
}
if (result.success == false) {
code = 400
}
result.name = result.name.replace(/\u002B/g, '%20')
if (dc == false) {
result = result
}
if (!dc || dc == true) {
result.name = decodeURIComponent(result.name)
}
let response = new Response(JSON.stringify(result), {
status: code,
headers: {
Expand Down

0 comments on commit ca3c7fd

Please sign in to comment.