mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 13:31:06 +00:00
Improved findTitle
to work with tag attributes
This commit is contained in:
parent
2d18bac619
commit
a76f9f37aa
15
src/htmx.js
15
src/htmx.js
@ -707,15 +707,12 @@ return (function () {
|
||||
}
|
||||
}
|
||||
|
||||
var TITLE_FINDER = /<title>([\s\S]+?)<\/title>/im;
|
||||
function findTitle(content) {
|
||||
if(content.indexOf('<title>') > -1 &&
|
||||
(content.indexOf('<svg>') == -1 ||
|
||||
content.indexOf('<title>') < content.indexOf('<svg>'))) {
|
||||
var result = TITLE_FINDER.exec(content);
|
||||
if (result) {
|
||||
return result[1];
|
||||
}
|
||||
function findTitle(content) {
|
||||
var contentWithSvgsRemoved = content.replace('/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim', '');
|
||||
var result = contentWithSvgsRemoved.match('/<title(\s[^>]*>|>)([\s\S]*?)<\/title>/im');
|
||||
|
||||
if (result) {
|
||||
return result[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user