rit-sse / node-api

💯 The SSE New and Improved Unified API
https://sse.rit.edu/api/v2
MIT License
8 stars 9 forks source link

Handle slashes in go links #109

Closed gavrielrh closed 4 years ago

gavrielrh commented 4 years ago

Problem: If a go-link has a / in its name, any PUT/DELETEs referencing it will fail, as the / causes ExpressJS to interpret the request as a separate route.

Solution: By using a wildcard regxp for the route path (https://expressjs.com/en/guide/routing.html#route-paths) eg: /:shortLink(*) ExpressJS will glob anything after the matching part of the route, handling the remainder appropriately. req.params.shortLink will still return back the whole go-link, so this should have no impact on other links, even if they also start with the same prefix/

resolves #94