urania-dev / snapp

Yet Another Url Shortner. A simple excercise to learn Svelte.
https://snapp.li
MIT License
210 stars 11 forks source link

API doesn't have same error handling as dashboard #71

Closed lit-carlos closed 1 week ago

lit-carlos commented 2 weeks ago

Through the API, adding a snapp test/test, goes through with no issues. On the dashboard, this is avoided but not taking the / on the shortcode field.

urania-dev commented 2 weeks ago

What? XD

Edit: forgive me but i don't understand whats the bug

lit-carlos commented 2 weeks ago

If you use this on the API:

curl -X POST http://localhost:3000/api/snapps \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_TOKEN" \ -d '{ "shortcode": "test/geo", "original_url": "https://example.com", "notes": "GeoIP Test", "disabled": false, "tags": ["test"] }'

It will succeed, but the shortcode will have the / and therefore invalid. I guess the fix is just some validation on the API. On the Dashboard, you can't make this mistake because because it doesn't let you use a / on the shortcode field.

urania-dev commented 1 week ago

should be already fixed :)