Skip to content

Commit 245db60

Browse files
Karsten Krausmislav
authored andcommitted
Handle documents with no or empty <head> tags
Closes #625
1 parent c19287e commit 245db60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

jquery.pjax.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,9 @@ function extractContainer(data, xhr, options) {
667667

668668
// Attempt to parse response html into elements
669669
if (fullDocument) {
670-
var $head = $(parseHTML(data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0]))
671670
var $body = $(parseHTML(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0]))
671+
var head = data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)
672+
var $head = head != null ? $(parseHTML(head[0])) : $body
672673
} else {
673674
var $head = $body = $(parseHTML(data))
674675
}

0 commit comments

Comments
 (0)