= UrlbarUtils.stripPrefixAndTrim(inputedURL, {
      stripHttp: true,
      stripHttps: true,
      stripWww: true,
      trimEmptyQuery: true,
    });
    const connection = await lazy.PlacesUtils.promiseLargeCacheDBConnection();
    const resultSet = await connection.executeCached(
      `
      SELECT url, IIF(last_visit_date NOTNULL, h.title, b.title) AS _title, frecency
      FROM moz_places h
      LEFT JOIN moz_bookmarks b ON b.fk = h.id
      WHERE
        url_hash IN (
          hash('https://' || :strippedURL),
          hash('https://www.' || :strippedURL),
          hash('http://' || :strippedURL),
          hash('http://www.' || :strippedURL)
        )
        AND frecency <> 0
      ORDER BY
        _title NOTNULL DESC,
        _title || '/' <> :strippedURL DESC,
        h.url = :inputedURL DESC,
        h.frecency DESC,
        h.id DESC
      LIMIT 1
      `,
      { inputedURL, strippedURL }
    );

    if (!resultSet.length) {
      return null;
    }

    const title = resultSet[0].getResultByName("_title");
    if (!title) {
      return null;
    }

    return new lazy.UrlbarResult({
      type: UrlbarUtils.RESULT_TYPE.URL,
      source: UrlbarUtils.RESULT_SOURCE.HISTORY,
      heuristic: true,
      payload: {
        url: inputedURL,
        title,
        icon: UrlbarUtils.getIconForUrl(resultSet[0].getResultByName("url")),
      },
      highlights: {
        url: UrlbarUtils.HIGHLIGHT.TYPED,
      },
    });
  }
}
PK