Skip to content

Commit

Permalink
Merge pull request #5346 from kenjis/refactor-request-uri
Browse files Browse the repository at this point in the history
refactor: replace $request->uri with $request->getUri()
  • Loading branch information
kenjis committed Nov 20, 2021
2 parents 13af9e5 + 1945401 commit 03f5195
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/Views/errors/html/error_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<tbody>
<tr>
<td style="width: 10em">Path</td>
<td><?= esc($request->uri) ?></td>
<td><?= esc($request->getUri()) ?></td>
</tr>
<tr>
<td>HTTP Method</td>
Expand Down
6 changes: 3 additions & 3 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ function force_https(int $duration = 31536000, ?RequestInterface $request = null
$uri = URI::createURIString(
'https',
$baseURL,
$request->uri->getPath(), // Absolute URIs should use a "/" for an empty path
$request->uri->getQuery(),
$request->uri->getFragment()
$request->getUri()->getPath(), // Absolute URIs should use a "/" for an empty path
$request->getUri()->getQuery(),
$request->getUri()->getFragment()
);

// Set an HSTS header
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/IncomingRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,6 @@ public function testSetPathUpdatesURI()

$request->setPath('apples');

$this->assertSame('apples', $request->uri->getPath());
$this->assertSame('apples', $request->getUri()->getPath());
}
}
14 changes: 7 additions & 7 deletions tests/system/HTTP/URITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,14 +876,14 @@ public function testBasedNoIndex()

// going through request
$this->assertSame('http://example.com/ci/v4/controller/method', (string) $request->uri);
$this->assertSame('/ci/v4/controller/method', $request->uri->getPath());
$this->assertSame('/ci/v4/controller/method', $request->getUri()->getPath());

// standalone
$uri = new URI('http://example.com/ci/v4/controller/method');
$this->assertSame('http://example.com/ci/v4/controller/method', (string) $uri);
$this->assertSame('/ci/v4/controller/method', $uri->getPath());

$this->assertSame($uri->getPath(), $request->uri->getPath());
$this->assertSame($uri->getPath(), $request->getUri()->getPath());
}

public function testBasedWithIndex()
Expand All @@ -902,15 +902,15 @@ public function testBasedWithIndex()
Services::injectMock('request', $request);

// going through request
$this->assertSame('http://example.com/ci/v4/index.php/controller/method', (string) $request->uri);
$this->assertSame('/ci/v4/index.php/controller/method', $request->uri->getPath());
$this->assertSame('http://example.com/ci/v4/index.php/controller/method', (string) $request->getUri());
$this->assertSame('/ci/v4/index.php/controller/method', $request->getUri()->getPath());

// standalone
$uri = new URI('http://example.com/ci/v4/index.php/controller/method');
$this->assertSame('http://example.com/ci/v4/index.php/controller/method', (string) $uri);
$this->assertSame('/ci/v4/index.php/controller/method', $uri->getPath());

$this->assertSame($uri->getPath(), $request->uri->getPath());
$this->assertSame($uri->getPath(), $request->getUri()->getPath());
}

public function testForceGlobalSecureRequests()
Expand All @@ -933,13 +933,13 @@ public function testForceGlobalSecureRequests()
Services::injectMock('request', $request);

// Detected by request
$this->assertSame('https://example.com/ci/v4/controller/method', (string) $request->uri);
$this->assertSame('https://example.com/ci/v4/controller/method', (string) $request->getUri());

// Standalone
$uri = new URI('http://example.com/ci/v4/controller/method');
$this->assertSame('https://example.com/ci/v4/controller/method', (string) $uri);

$this->assertSame(trim($uri->getPath(), '/'), trim($request->uri->getPath(), '/'));
$this->assertSame(trim($uri->getPath(), '/'), trim($request->getUri()->getPath(), '/'));
}

public function testZeroAsURIPath()
Expand Down

0 comments on commit 03f5195

Please sign in to comment.