Skip to content

Commit

Permalink
Align extension handling with url path trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Feb 5, 2019
1 parent 30fab4f commit 7052430
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/CardDav/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Backend
*
* @var string
*/
private $url_vcard_extension = '.vcf';
private $vcard_extension = '.vcf';

/**
* Progress callback
Expand Down Expand Up @@ -84,7 +84,7 @@ public function setUrl(string $url)

// workaround for providers that don't use the default .vcf extension
if (strpos($this->url, "google.com")) {
$this->url_vcard_extension = '';
$this->vcard_extension = '';
}
}

Expand Down Expand Up @@ -186,12 +186,12 @@ public function getLinkedData(string $uri): array
* Gets a clean vCard from the CardDAV server
*
* @param string $vcard_id vCard id on the CardDAV server
* @return stdClass vCard (text/vcard)
* @return stdClass vCard (text/vcard)
*/
public function getVcard(string $vcard_id): stdClass
{
$vcard_id = str_replace($this->url_vcard_extension, '', $vcard_id);
$response = $this->getClient()->request('GET', $this->url . $vcard_id . $this->url_vcard_extension);
$id = rtrim($vcard_id, $this->vcard_extension) . $this->vcard_extension;
$response = $this->getClient()->request('GET', $this->url . $id);

$body = (string)$response->getBody();

Expand Down Expand Up @@ -227,7 +227,7 @@ private function processPropFindResponse(string $response): array
if ((preg_match('/vcard/', $response->propstat->prop->getcontenttype) || preg_match('/vcf/', $response->href)) &&
!$response->propstat->prop->resourcetype->collection) {
$id = basename($response->href);
$id = str_replace($this->url_vcard_extension, '', $id);
$id = str_replace($this->vcard_extension, '', $id);

$cards[] = $this->getVcard($id);
}
Expand Down

0 comments on commit 7052430

Please sign in to comment.