Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117374925
D1600.1774819440.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D1600.1774819440.diff
View Options
diff --git a/src/app/Providers/Payment/Stripe.php b/src/app/Providers/Payment/Stripe.php
--- a/src/app/Providers/Payment/Stripe.php
+++ b/src/app/Providers/Payment/Stripe.php
@@ -70,8 +70,8 @@
$request = [
'customer' => $customer_id,
- 'cancel_url' => \url('/wallet'), // required
- 'success_url' => \url('/wallet'), // required
+ 'cancel_url' => Utils::serviceUrl('/wallet'), // required
+ 'success_url' => Utils::serviceUrl('/wallet'), // required
'payment_method_types' => ['card'], // required
'locale' => 'en',
'mode' => 'setup',
@@ -181,8 +181,8 @@
$request = [
'customer' => $customer_id,
- 'cancel_url' => \url('/wallet'), // required
- 'success_url' => \url('/wallet'), // required
+ 'cancel_url' => Utils::serviceUrl('/wallet'), // required
+ 'success_url' => Utils::serviceUrl('/wallet'), // required
'payment_method_types' => ['card'], // required
'locale' => 'en',
'line_items' => [
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -116,20 +116,13 @@
*/
public static function serviceUrl(string $route): string
{
- return trim(\config('app.public_url'), '/') . '/' . ltrim($route, '/');
+ $url = \config('app.public_url');
- // TODO: Investigate why it does not work
-
- $url = \secure_url($route);
-
- $app_url = trim(\config('app.url'), '/');
- $pub_url = trim(\config('app.public_url'), '/');
-
- if ($pub_url != $app_url) {
- $url = str_replace($app_url, $pub_url, $url);
+ if (!$url) {
+ $url = \config('app.url');
}
- return $url;
+ return rtrim(trim($url, '/') . '/' . ltrim($route, '/'), '/');
}
/**
diff --git a/src/tests/Unit/UtilsTest.php b/src/tests/Unit/UtilsTest.php
--- a/src/tests/Unit/UtilsTest.php
+++ b/src/tests/Unit/UtilsTest.php
@@ -9,10 +9,8 @@
{
/**
* Test for Utils::powerSet()
- *
- * @return void
*/
- public function testPowerSet()
+ public function testPowerSet(): void
{
$set = [];
@@ -55,11 +53,36 @@
}
/**
+ * Test for Utils::serviceUrl()
+ */
+ public function testServiceUrl(): void
+ {
+ $public_href = 'https://public.url/cockpit';
+ $local_href = 'https://local.url/cockpit';
+
+ \config([
+ 'app.url' => $local_href,
+ 'app.public_url' => '',
+ ]);
+
+ $this->assertSame($local_href, Utils::serviceUrl(''));
+ $this->assertSame($local_href . '/unknown', Utils::serviceUrl('unknown'));
+ $this->assertSame($local_href . '/unknown', Utils::serviceUrl('/unknown'));
+
+ \config([
+ 'app.url' => $local_href,
+ 'app.public_url' => $public_href,
+ ]);
+
+ $this->assertSame($public_href, Utils::serviceUrl(''));
+ $this->assertSame($public_href . '/unknown', Utils::serviceUrl('unknown'));
+ $this->assertSame($public_href . '/unknown', Utils::serviceUrl('/unknown'));
+ }
+
+ /**
* Test for Utils::uuidInt()
- *
- * @return void
*/
- public function testUuidInt()
+ public function testUuidInt(): void
{
$result = Utils::uuidInt();
@@ -69,10 +92,8 @@
/**
* Test for Utils::uuidStr()
- *
- * @return void
*/
- public function testUuidStr()
+ public function testUuidStr(): void
{
$result = Utils::uuidStr();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 29, 9:24 PM (1 w, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18734679
Default Alt Text
D1600.1774819440.diff (3 KB)
Attached To
Mode
D1600: Fix Utils::serviceUrl()
Attached
Detach File
Event Timeline