Repository: python-gitlab/python-gitlab

Issue:
projects.get() raises error when project is specified as "userspace/name" rather than ID
## Description of the problem, including code/CLI snippet

Attempt to make a query using the project's path, per the [example in the documentation](https://github.com/python-gitlab/python-gitlab/blame/v1.12.1/docs/gl_objects/projects.rst#L68).

```python
gl.projects.get('mygroup/myname')
```

## Expected Behavior

python-gitlab resolves the group and project name, returning a `Project` object for that project.

## Actual Behavior

Exception is raised with the following error:

```
Error encountered triggering pipeline: 404: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /api/v4/projects/mygroup/myname was not found on this server.</p>
</body></html>
```

From the URL in the error, it appears that the project is not being resolved at all and that python-gitlab is assuming the value passed in was the project ID.

## Specifications

  - python-gitlab version: 1.12.1
  - API version you are using (v3/v4): v4
  - Gitlab server version (or gitlab.com): 11.11.2



Discussion:
I'm pretty sure this is a doc bug, https://docs.gitlab.com/ee/api/projects.html#get-single-project does also provide a get project by id endpoint only.
Yeah, I had suspected this might be the case, as I am relatively familiar with the API and know you can't get the project by anything but the ID.

I can work around this by using `projects.list(search='myname')` and then checking each match to see if the namespace and project name both match. So, at the end of the day it's not a blocker for me.

If the solution is a doc fix, I can submit a pull request. However, if it is deemed useful to add this functionality, I would need to roll up my sleeves and get more familiar with the codebase.
Whould be awesome to get a contribution within the docs on this from your side.
Cool, just opened https://github.com/python-gitlab/python-gitlab/pull/914
If you read correctly on the doc link @bufferoverflow provided, it says `The ID or URL-encoded path of the project`.

The project's doc was correctly but the feature is not working, and I'm not sure why. It appears to me that it's querying the correct endpoint.

I'd preffer to reopen this issue rather than opening a new one :)

The reply of both the id and the project path are the same.

https://salsa.debian.org/api/v4/projects/27916
https://salsa.debian.org/api/v4/projects/salsa-ci-team%2Fpipeline
It happen to work on gitlab.com, but not on the instance I previously shared.

```python
In [1]: import gitlab

In [2]: gl = gitlab.Gitlab('https://gitlab.com')

In [3]: gl.projects.get('inakimalerba/test-project')
Out[3]: <Project id:13176136>
```
I'm trying to debug the reason behind the failure. 

It's possible that the instance admins might have blocked some kind of requests, but the endpoint works good with any other requests.

 ```python
In [5]: import requests

In [6]: session = requests.Session()
   ...: session.headers.update({'User-Agent': 'Mozilla/5.0'})
   ...: 

In [7]: gl = gitlab.Gitlab('https://salsa.debian.org/', session=session)

In [8]: gl.projects.get("salsa-ci-team/pipeline")

[...]

/home/ina/.local/lib/python3.7/site-packages/gitlab/exceptions.py in wrapped_f(*args, **kwargs)
    259                 return f(*args, **kwargs)
    260             except GitlabHttpError as e:
--> 261                 raise error(e.error_message, e.response_code, e.response_body)
    262 
    263         return wrapped_f

GitlabGetError: 404: 404 Project Not Found
```

```bash
$ curl https://salsa.debian.org/api/v4/projects/salsa-ci-team%2Fpipeline
{"id":27916,"description":"♻️ Gitlab CI pipeline definition to build and test Debian projects.","name":"pipeline","name_with_namespace":"Salsa CI Team / pipeline","path":"pipeline","path_with_namespace":"salsa-ci-team/pipeline","created_at":"2018-06-11T16:18:20.834Z","default_branch":"master","tag_list":["autopkgtest","blhc","build","ci","debian","gbp","lintian","package","pipeline","piuparts","reprotest","salsa","test"],"ssh_url_to_repo":"git@salsa.debian.org:salsa-ci-team/pipeline.git","http_url_to_repo":"https://salsa.debian.org/salsa-ci-team/pipeline.git","web_url":"https://salsa.debian.org/salsa-ci-team/pipeline","readme_url":"https://salsa.debian.org/salsa-ci-team/pipeline/blob/master/README.md","avatar_url":null,"star_count":23,"forks_count":32,"last_activity_at":"2019-10-31T19:35:43.180Z","namespace":{"id":3783,"name":"Salsa CI Team","path":"salsa-ci-team","kind":"group","full_path":"salsa-ci-team","parent_id":null,"avatar_url":null,"web_url":"https://salsa.debian.org/groups/salsa-ci-team"}}
```

Edit: Oops I wrote a lengthy comment but actually it's a simple issue with your trailing slash. I added some debug prints in `_build_url()` and get this:

```repl
>>> import gitlab
>>>
>>> gl = gitlab.Gitlab('https://gitlab.com/')
>>> gl.projects.get('inakimalerba/test-project')
Constructed URL:
https://gitlab.com//api/v4/projects/inakimalerba%2Ftest-project
<Project id:13176136>
>>>
>>> gl = gitlab.Gitlab('https://salsa.debian.org/')
>>> gl.projects.get("salsa-ci-team/pipeline")
Constructed URL:
https://salsa.debian.org//api/v4/projects/salsa-ci-team%2Fpipeline
Traceback (most recent call last):
```

So the proxy on gitlab.com handles the double slash but not Apache on salsa.debian.org. For now, removing the trailing slash will work, and for python-gitlab just stripping the trailing slash for the gitlab URL would probably be enough :)

Resolving patch:
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -90,8 +90,8 @@ def __init__(
 
         self._api_version = str(api_version)
         self._server_version = self._server_revision = None
-        self._base_url = url
-        self._url = "%s/api/v%s" % (url, api_version)
+        self._base_url = url.rstrip("/")
+        self._url = "%s/api/v%s" % (self._base_url, api_version)
         #: Timeout to use for requests to gitlab server
         self.timeout = timeout
         #: Headers that will be used in request to GitLab


Test patch:
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -376,6 +376,23 @@ def resp_cont(url, request):
             self.assertRaises(GitlabHttpError, self.gl.http_delete, "/not_there")
 
 
+class TestGitlabStripBaseUrl(unittest.TestCase):
+    def setUp(self):
+        self.gl = Gitlab(
+            "http://localhost/", private_token="private_token", api_version=4
+        )
+
+    def test_strip_base_url(self):
+        self.assertEqual(self.gl.url, "http://localhost")
+
+    def test_strip_api_url(self):
+        self.assertEqual(self.gl.api_url, "http://localhost/api/v4")
+
+    def test_build_url(self):
+        r = self.gl._build_url("/projects")
+        self.assertEqual(r, "http://localhost/api/v4/projects")
+
+
 class TestGitlabAuth(unittest.TestCase):
     def test_invalid_auth_args(self):
         self.assertRaises(