mirror of
https://github.com/zen-browser/desktop.git
synced 2026-05-28 07:45:09 +00:00
43 lines
1.9 KiB
C++
43 lines
1.9 KiB
C++
diff --git a/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs b/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs
|
|
index 1e159d12ffdc39be87046689b05022813ea925ac..cba7168eeffa54d2c576982927f096b21e039c83 100644
|
|
--- a/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs
|
|
+++ b/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs
|
|
@@ -77,22 +77,26 @@ export class UrlbarProviderHeuristicFallback extends UrlbarProvider {
|
|
// Since we can't tell if this is a real URL and whether the user wants
|
|
// to visit or search for it, we provide an alternative searchengine
|
|
// match if the string looks like an alphanumeric origin or an e-mail.
|
|
- let str = queryContext.searchString;
|
|
- if (!URL.canParse(str)) {
|
|
- if (
|
|
- lazy.UrlbarPrefs.get("keyword.enabled") &&
|
|
- (lazy.UrlUtils.looksLikeOrigin(str, {
|
|
- noIp: true,
|
|
- noPort: true,
|
|
- }) ||
|
|
- lazy.UrlUtils.REGEXP_COMMON_EMAIL.test(str))
|
|
- ) {
|
|
+ let trimmedSearchString = queryContext.trimmedSearchString;
|
|
+ let [searchCandidate] = UrlbarUtils.stripPrefixAndTrim(
|
|
+ trimmedSearchString,
|
|
+ {
|
|
+ trimSlash: true,
|
|
+ }
|
|
+ );
|
|
+ if (
|
|
+ lazy.UrlbarPrefs.get("keyword.enabled") &&
|
|
+ (lazy.UrlUtils.looksLikeUrl(searchCandidate) ||
|
|
+ lazy.UrlUtils.looksLikeOrigin(searchCandidate, {
|
|
+ allowPartialNumericalTLDs: true,
|
|
+ }) !== lazy.UrlUtils.LOOKS_LIKE_ORIGIN.NONE ||
|
|
+ lazy.UrlUtils.REGEXP_COMMON_EMAIL.test(trimmedSearchString))
|
|
+ ) {
|
|
let searchResult = await this._engineSearchResult({ queryContext });
|
|
if (instance != this.queryInstance) {
|
|
return;
|
|
}
|
|
addCallback(this, searchResult);
|
|
- }
|
|
}
|
|
return;
|
|
}
|