Skip to content

Commit 1450026

Browse files
committed
feat: discard route if there's only one point
1 parent de5e4cc commit 1450026

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

api/click.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ export default function handler(req, res) {
151151
sill(`Requesting ${request_uri}`);
152152
const fetch_debug_response = fetch(request_uri).then((response) => {
153153
return response.json();
154-
});
155-
fetch_debug_response.then((debug_response) => {
154+
}).then((debug_response) => {
156155
// sill(debug_response);
157156
let ps = {};
158157
let ws = {};
@@ -163,7 +162,8 @@ export default function handler(req, res) {
163162
ws[it.id] = it.nodes;
164163
}
165164
});
166-
const path_found = shortest_path(ps, ws, pts[0], pts[pts.length - 1]);
165+
sill(pts.length);
166+
const path_found = pts.length < 2 ? [] : shortest_path(ps, ws, pts[0], pts[pts.length - 1]);
167167
res.status(200).json({
168168
log: `Method: click\nArgs: ${pts}\nStatus: requested "${request_uri}", got response ${JSON.stringify(debug_response.elements)}`,
169169
multipolyline: JSON.stringify(path_found),

0 commit comments

Comments
 (0)