Skip to content
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

Making 'get' and 'post' methods more intuitive #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

exos
Copy link

@exos exos commented Jun 20, 2013

Sorry my english, this is a small commit. Actualy you need start with "/" and apply the ".json" extension in methods get/post's urls.

This does not intuitive:

get('/users/show.json',{screen_name: 'exos'}, function (err, res) {
    ...
});

instead of presume a url not begun by "/" is a complete URL, I presumed opposite:

get('users/show',{screen_name: 'exos'}, function (err, res) {
    ...
});

In my version is correct, and translate to https://api.twitter.com/1.1//users/show.json?screen_name=exos

For compatibility the follows urls are accepted:

  • 'users/show'
  • '/users/show'
  • 'users/show.json'
  • '/users/show.json'

But, if an url start with http://, https://, somestring:// the url has considerate absolute. Ex 'http://anotherhost.com/users/show.nojson' is'nt translate.


var params = params || null;

if (!url.match(/^[\w]+:\/\//)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It considers any protocol, you can replace this by:

if (!url.match(/^https?:\/\//i)) { 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant