summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2022-05-09 15:44:40 +0200
committerGitHub <noreply@github.com>2022-05-09 15:44:40 +0200
commit30f62de1816439ba5920abfbede0721d568b8962 (patch)
tree18d409086596b1cfb3f1ece58956dc0c66f3459d
parent61552f92fcf8a33e9796c7ff93d1872ee68d9a2e (diff)
parenta0c5f0e1fb3c3e579637f78e7c218ce6cb0c2db5 (diff)
Merge pull request #131 from jesterpm/fix-location-header
Use parse_headers for media endpoint uploads
-rw-r--r--lib/helpers.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index 48ada12..ec23afa 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -120,8 +120,8 @@ function micropub_media_post_for_user(&$user, $file) {
$r = micropub_post($user->micropub_media_endpoint, [], $user->micropub_access_token, $file, true, 'file');
// Check the response and look for a "Location" header containing the URL
- if($r['response'] && preg_match('/Location: (.+)/', $r['response'], $match)) {
- $r['location'] = trim($match[1]);
+ if($r['headers'] && $r['headers']['Location']) {
+ $r['location'] = $r['headers']['Location'];
} else {
$r['location'] = false;
}