You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,16 +161,18 @@ if ( $banners ) {
161
161
162
162
// Iterate over the result
163
163
foreach($banners as $pos => $a) {
164
-
$links[$pos] = $a->attr('href'); // get absolute URL from href property
164
+
// $a->href property is the resolved $a->attr('href') relative to the
165
+
// documents <basehref=...>, if present, or $doc->baseURL.
166
+
$links[$pos] = $a->href; // get absolute URL from href property
165
167
$titles[$pos] = trim($a->text()); // strip all HTML tags and leave just text
166
168
167
169
// Filter the result
168
170
if ( !$a->hasClass('logo') ) {
169
-
// $a->style property is the parsed $a->attr('style')
171
+
// $a->style property is the parsed $a->attr('style'), same as $a->attr('style', true)
170
172
if ( strtolower($a->style['position']) == 'fixed' ) continue;
171
173
172
174
$img = $a->find('img')[0]; // ArrayAccess
173
-
if ( $img ) $images[$pos] = $img->src; // short for $img->attr('src')
175
+
if ( $img ) $images[$pos] = $img->src; // short for $img->attr('src', true)
174
176
}
175
177
}
176
178
@@ -190,6 +192,13 @@ $charset = $doc->charset;
190
192
191
193
// Get the size of the document ( strlen($html) )
192
194
$size = $doc->size;
195
+
196
+
// The URL at which the document was requested
197
+
$requestUri = $doc->href;
198
+
199
+
// <basehref=...>, if present, or the origin + dir path part from $doc->href.
200
+
// The .href and .src props are resolved using this value.
201
+
$baseURL = $doc->baseURL;
193
202
```
194
203
195
204
Note: In case the charset meta attribute has a wrong value or the internal conversion fails for any other reason, `hQuery` would ignore the error and continue processing with the original HTML, but would register an error message on `$doc->html_errors['convert_encoding']`.
0 commit comments