search for standard sites pub-search.waow.tech
search zig blog atproto

fix: respect quoted @handle as literal search, not author filter

"@zzstoatzz.io" searches for the text literally.
@zzstoatzz.io (unquoted) triggers author filter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+7 -5
+7 -5
site/index.html
··· 835 835 <div class="syntax-help" id="syntax-help"> 836 836 <div class="syntax-row"><span class="syntax-example"><code>cat dog</code></span><span class="syntax-desc">matches either term</span></div> 837 837 <div class="syntax-row"><span class="syntax-example"><code>"exact phrase"</code></span><span class="syntax-desc">matches exact phrase</span></div> 838 - <div class="syntax-row"><span class="syntax-example"><code>@handle query</code></span><span class="syntax-desc">filter by author</span></div> 838 + <div class="syntax-row"><span class="syntax-example"><code>@handle query</code></span><span class="syntax-desc">filter by author (quote to search literally)</span></div> 839 839 </div> 840 840 841 841 <div id="mode-toggle" class="mode-toggle"></div> ··· 1267 1267 } 1268 1268 1269 1269 function doSearch() { 1270 - // parse @handle from query text 1270 + // parse @handle from query text (only if not inside quotes) 1271 1271 const raw = queryInput.value; 1272 - const authorMatch = raw.match(/(?:^|\s)@([\w.-]+\.\w+)(?:\s|$)/); 1272 + // match @handle that's NOT inside quotes — look for unquoted @handle.tld pattern 1273 + const unquoted = raw.replace(/"[^"]*"/g, ''); // strip quoted sections 1274 + const authorMatch = unquoted.match(/(?:^|\s)@([\w.-]+\.\w+)/); 1273 1275 if (authorMatch) { 1274 1276 const handle = authorMatch[1]; 1275 - // strip @handle from query, clean up whitespace 1276 - queryInput.value = raw.replace(/@[\w.-]+\.\w+/, '').replace(/\s+/g, ' ').trim(); 1277 + // strip the @handle from the original query (not the unquoted version) 1278 + queryInput.value = raw.replace(new RegExp('\\s*@' + handle.replace(/\./g, '\\.') + '\\s*'), ' ').trim(); 1277 1279 currentAuthor = handle; 1278 1280 renderActiveFilter(); 1279 1281 }