Docker-Hub-API icon indicating copy to clipboard operation
Docker-Hub-API copied to clipboard

cannot get top repositories from official user `library`

Open fluency03 opened this issue 8 years ago • 4 comments
trafficstars

At this line: https://github.com/RyanTheAllmighty/Docker-Hub-API/blob/develop/src/api.js#L762

        /**
         * Gets the details about a repository.
         *
         * @param {String} [username] - the username of the repository to get information about. If left out or '_' is provided then it will query the official Docker repository with the given name
         * @param {String} name - the name of the repository to get information about
         * @returns {Promise}
         */
        repository: function (username, name) {
            // If no name is passed in, then the user wants an official repository
            if (username && !name) {
                name = username;
                username = 'library';
            }

            // If username is '_' then we're trying to get an official repository
            if (username === '_') {
                username = 'library';
            }

            // Make sure the username is all lowercase as per Docker Hub requirements
            username = username.toLowerCase();

            return this.makeGetRequest(`repositories/${username}/${name}`);
        },

Here:

            if (username && !name) {
                name = username;
                username = 'library';
            }

In your case, if I give dockerHubApi.repository('_'), the actual request is repositories/library/_, which is expecting error.

I think should be:

            if (!username && !name) { // here, should be, !username && !name
                name ='';
                username = 'library';
            }

fluency03 avatar Apr 15 '17 21:04 fluency03

I think it may make sense to put that functionality into it's own method since I don't feel it fits within thew scope or looking for a specific repository. Something like topRepositoriesForUser.

Looking back on this API now and it's written in such a strange way to how I do things now :\

Either way, I'll add in a method to do this and publish a new version in a couple days.

I'll close the issue when done and published.

RyanTheAllmighty avatar Apr 16 '17 00:04 RyanTheAllmighty

Any luck?

KeesCBakker avatar Apr 16 '18 17:04 KeesCBakker

I've got some time set aside over the next couple days to look through the issues and be a good maintainer :)

RyanTheAllmighty avatar Apr 17 '18 02:04 RyanTheAllmighty

Wait so looking at this and you're looking to make this api call:

https://hub.docker.com/v2/repositories/library/

To get a users repositories?

If so there is a repositories(username) function.

Let me know if I'm misunderstanding

RyanTheAllmighty avatar Apr 17 '18 07:04 RyanTheAllmighty