Skip to content

Commit 4e3b6ed

Browse files
committed
fix: search for 'space' not allowed
1 parent 25ad5e0 commit 4e3b6ed

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/controllers/detect.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export const detect = (app: FastifyInstance) => {
77
return async (request: FastifyRequest<{ Querystring: DetectQueries }>, reply: FastifyReply) => {
88
const { latitude, longitude } = request.query
99

10-
if (!latitude || !longitude) {
10+
if (
11+
typeof latitude === 'undefined' ||
12+
latitude.toString().trim() === '' ||
13+
typeof longitude === 'undefined' ||
14+
longitude.toString().trim() === ''
15+
) {
1116
return sendBadRequest(reply, "The 'latitude' and 'longitude' parameters is required.")
1217
}
1318

app/controllers/search.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const search = (app: FastifyInstance) => {
77
const { q } = request.query
88
// TODO: search by province, regency, or district
99

10-
if (!q) {
10+
if (typeof q === 'undefined' || q.trim() === '') {
1111
return sendBadRequest(reply, "The 'q' parameter is required.")
1212
}
1313

0 commit comments

Comments
 (0)