Skip to content

Commit 725961d

Browse files
Merge pull request #106 from solocommand/prefix
Support prefixes of the REST endpoint
2 parents 9c72ecc + 84164ce commit 725961d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Rest/RestRequest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ public function getUrl()
159159
);
160160
}
161161

162+
protected function adjustRootEndpoint($path)
163+
{
164+
$root = $this->config->getRootEndpoint();
165+
if (0 !== strpos($path, $root)) {
166+
$end = strrpos($path, $root) + strlen($root);
167+
$endpoint = substr($path, 0, $end);
168+
$this->config->setRootEndpoint($endpoint);
169+
}
170+
}
171+
162172
/**
163173
* Gets the scheme, such as http or https.
164174
*
@@ -549,6 +559,8 @@ private function parse($uri)
549559
throw RestException::invalidEndpoint($this->parsedUri['path']);
550560
}
551561

562+
$this->adjustRootEndpoint($this->parsedUri['path']);
563+
552564
$this->parsedUri['path'] = str_replace($this->config->getRootEndpoint(), '', $this->parsedUri['path']);
553565
$this->parsePath($this->parsedUri['path']);
554566

0 commit comments

Comments
 (0)