Skip to content

Commit ef2ef9b

Browse files
committed
Fix error when use head base-href
Fixes #3172
1 parent dc502d0 commit ef2ef9b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

web/search.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,13 @@ String _decodeHtml(String html) {
528528
final _relativePath = () {
529529
var body = document.querySelector('body')!;
530530
var relativePath = '';
531-
if (body.getAttribute('data-using-base-href') == 'true') {
532-
relativePath = body.getAttribute('href')!;
533-
} else if (body.getAttribute('data-base-href') == '') {
534-
relativePath = './';
535-
} else {
536-
relativePath = body.getAttribute('data-base-href')!;
531+
if (body.getAttribute('data-using-base-href') == 'false') {
532+
var baseHref = body.getAttribute('data-base-href');
533+
if (baseHref == null || baseHref.isEmpty) {
534+
relativePath = './';
535+
} else {
536+
relativePath = baseHref;
537+
}
537538
}
538539
var href = Uri.parse(window.location.href);
539540
var base = href.resolve(relativePath);

0 commit comments

Comments
 (0)