psolbach / iconbin

Beautiful favicons API
27 stars 2 forks source link

Non-JSON reply when using bad URL #20

Closed graypegg closed 8 years ago

graypegg commented 8 years ago

The client gets sent not a valid URL. in plaintext instead of a JSON object with a err property like a properly formatted URL that isn't found in the database does. I know it returns a 404 error, but error reporting should be kept consistent, thus the server should always return JSON data.

Recreating the issue:

$> curl -v https://iconbin.com/api/%22

returns:

*   Trying 149.210.164.114...
* Connected to iconbin.com (149.210.164.114) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: iconbin.com
* Server certificate: Let's Encrypt Authority X1
* Server certificate: DST Root CA X3
> GET /api/%22 HTTP/1.1
> Host: iconbin.com
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Wed, 08 Jun 2016 23:57:22 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 16
< Connection: keep-alive
< X-Powered-By: Express
< ETag: W/"10-0DZ7vKidADPB5iyZeVh0og"
< 
* Connection #0 to host iconbin.com left intact
not a valid URL.
psolbach commented 8 years ago

You're right. Will fix that.