Skip to content

Commit

Permalink
Make institution website urls absolute, #6951
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gale committed Mar 23, 2015
1 parent e111b61 commit 7b2f107
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -96,6 +96,9 @@ public function execute($request)
$this->latitude = $contact->latitude;
$this->longitude = $contact->longitude;
}

// Ensure website URL has a scheme to force absolute URL #6951
$contact->setWebsite($this->addDefaultSchemeIfMissing($contact->getWebsite()));
}
}

Expand All @@ -121,4 +124,9 @@ protected function getPurifiedHtmlSnippet()

return $content;
}

private function addDefaultSchemeIfMissing($url)
{
return parse_url($url, PHP_URL_SCHEME) === null ? 'http://' . $url : $url;
}
}

1 comment on commit 7b2f107

@jraddaoui
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of saving it each time the repository is visited. Couldn't we just make that directly in the template?

Please sign in to comment.