Comments (3)
The problem is undefined
is a valid value for the href attribute, this is an issue in the website side.
A solution would be assume the "undefined" value as an empty value, but this opens the door to other values that must be considered empty like "null", "nil", etc. I don't know if make such assumptions is a good idea.
from embed.
Hmmm... Are the values null
, nil
etc also valid? My assumption is that there was some issue with JavaScript and the value has undefined
which surely isn't intentional. I mean, why would anybody want undefined
, etc here? I think it would be best if you handle it.
In this case, this small change should fix the issue.
From:
Embed/src/Detectors/Languages.php
Line 20 in 9cb2dff
To:
if (!$language || !$href || 'undefined' === $href) {
Full code:
<?php
declare(strict_types=1);
namespace Embed\Detectors;
class Languages extends Detector
{
/**
* @return \Psr\Http\Message\UriInterface[]
*/
public function detect(): array
{
$document = $this->extractor->getDocument();
$languages = array();
foreach ($document->select('.//link[@hreflang]')->nodes() as $node) {
$language = $node->getAttribute('hreflang');
$href = $node->getAttribute('href');
if (!$language || !$href || 'undefined' === $href) {
continue;
}
$languages[$language] = $this->extractor->resolveUri($href);
}
return $languages;
}
}
Alternatively is there something I can do to handle this case? I really don't know what the best solution would be here.
from embed.
In this case, I'd create a helper, so it can be used in other places. Something like:
function isEmpty($value) {
return empty($value) || $value === "undefined";
}
If you want to work on a PR, I'll review and merge it.
from embed.
Related Issues (20)
- Can Embed be used with proxies, and custom headers? Including for getMulti() requests? HOT 2
- Youtube option choose_bigger_image no longer works/removed HOT 2
- Test cannot retrieve page HOT 1
- How to display only html.description and html.tags HOT 4
- Smart/Curly Quotes Problem (Plus Emojis) HOT 1
- charset 1251 problem HOT 6
- Particular Website Shows Different URL contents HOT 3
- Stopped working with SPOTIFY HOT 1
- [Question] Vimeo with "Hide from Vimeo" setting but embeds allowed on specific domains HOT 4
- request's locale change support HOT 2
- psr/http-message V2 support?
- Maximum redirects followed instagram HOT 3
- New release? HOT 1
- Twitter embed->get returns null on production HOT 5
- Twitter extractor will retrieve "/home" instead of a tweet URL HOT 2
- Reddit data is very lacking
- The demo site is offline HOT 3
- It is not work for same domain
- wrong extracted data when fetching image link behind redirect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embed.