-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to a resource with an end slash #25
Comments
I mad this workaround (using a plugin) : fermata.registerPlugin("slashed", function (transport, baseURL) {
this.base = baseURL;
transport = transport.using('statusCheck').using('autoConvert', "application/json");
return function (request, callback) {
// If the last caracter of the path isn't a slash
if( String(request.path[request.path.length - 1]).substr(-1,1) !== "/") {
// Automatically adding a tail slash to the URL's end
request.path[request.path.length - 1] += "/";
// It's also possible to add an empty string
// request.path.push("");
}
transport(request, callback);
};
});
var site = fermata.slashed("http://api.example.org");
site.v1.instance["1"].get(console.log); // Works !
site.v1.instance["1/"].get(console.log); // Works too ! |
Cool, glad you were able to get a plugin working for this — I probably don't promote this enough in the docs, but plugins are intended to be lightweight enough to make one for every site whenever desirable. There's two ways you could get a slash at the end of a URL right now, by avoiding escaping with an array ( I'll leave this open for now in case there's any good clean general solutions, but a plugin might be the most appropriate solution in this sort of situation. |
Hi folks,
The module is great but I found a little issue with endpoints terminating by a slash.
Not works:
Works:
I didn't find option to add a slash automatically... Any help ?
Cheers,
The text was updated successfully, but these errors were encountered: