File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,6 @@ public function __construct(
7272 AuthenticationInterface $ authentication ,
7373 ClientInterface $ client = null
7474 ) {
75- //Regular expression to remove trailing slash
76- $ endpoint = preg_replace ('{/$} ' , '' , $ endpoint );
77-
7875 $ this ->setEndPoint ($ endpoint );
7976 $ this ->authentication = $ authentication ;
8077
@@ -109,6 +106,9 @@ public function setEndPoint($url)
109106 {
110107 $ this ->fields = array ();
111108
109+ //Regular expression to remove trailing slash
110+ $ url = rtrim ($ url , '/ ' );
111+
112112 $ this ->endpoint = $ url ;
113113 }
114114
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \chobie \Jira ;
4+
5+ use chobie \Jira \Api ;
6+ use chobie \Jira \Api \Authentication \Anonymous ;
7+
8+ /**
9+ * Class ApiTest
10+ *
11+ * @package Tests\chobie\Jira
12+ */
13+ class ApiTest extends \PHPUnit_Framework_TestCase
14+ {
15+ /**
16+ * Tests that any trailing slash in the endpoint url is removed before being stored in the object state
17+ */
18+ public function testSetEndpointTrailingSlash ()
19+ {
20+ $ api = new Api ('https://test.test/ ' , new Anonymous (), null );
21+ $ this ->assertEquals ('https://test.test ' , $ api ->getEndpoint ());
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments