Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vision v1.1 #365

Merged
merged 22 commits into from
Mar 2, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use better URL detection
  • Loading branch information
jdpedrie committed Feb 1, 2017
commit 30afcebff51bae2b2191e90d8dc5090d18c41546
14 changes: 13 additions & 1 deletion src/Vision/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Image

/**
* A map of short names to identifiers recognized by Cloud Vision.
*
* @var array
*/
private $featureShortNames = [
Expand All @@ -184,6 +185,17 @@ class Image
'web' => 'WEB_ANNOTATION'
];

/**
* A list of allowed url schemes.
*
* @var array
*/
private $urlSchemes = [
'http',
'https',
'gs'
];

/**
* Create an image with all required configuration.
*
Expand Down Expand Up @@ -225,7 +237,7 @@ public function __construct($image, array $features, array $options = [])
$this->features = $this->normalizeFeatures($features);

$this->image = $image;
if (is_string($image) && filter_var($image, FILTER_VALIDATE_URL)) {
if (is_string($image) && in_array(parse_url($image, PHP_URL_SCHEME), $this->urlSchemes)) {
$this->type = self::TYPE_URI;
} elseif (is_string($image)) {
$this->type = self::TYPE_STRING;
Expand Down