File tree Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change 1
1
import { decodeCursor , LIMIT , nextCursorEncoded } from '@/lib/cursor'
2
2
import { whenToFrom } from '@/lib/time'
3
3
import { getItem , itemQueryWithMeta , SELECT } from './item'
4
+ import { parse } from 'tldts'
4
5
5
6
function queryParts ( q ) {
6
7
const regex = / " ( [ ^ " ] * ) " / gm
@@ -253,24 +254,17 @@ export default {
253
254
254
255
// if search contains a url term, modify the query text
255
256
if ( url ) {
256
- const uri = url . slice ( 4 )
257
- let uriObj
258
- try {
259
- uriObj = new URL ( uri )
260
- } catch {
261
- try {
262
- uriObj = new URL ( `https://${ uri } ` )
263
- } catch { }
264
- }
265
-
266
- if ( uriObj ) {
267
- termQueries . push ( {
268
- wildcard : { url : `*${ uriObj ?. hostname ?? uri } ${ uriObj ?. pathname ?? '' } *` }
269
- } )
270
- termQueries . push ( {
271
- match : { text : `${ uriObj ?. hostname ?? uri } ${ uriObj ?. pathname ?? '' } ` }
272
- } )
257
+ let uri = url . slice ( 4 )
258
+ termQueries . push ( {
259
+ match_bool_prefix : { url : { query : uri , operator : 'and' , boost : 1000 } }
260
+ } )
261
+ const parsed = parse ( uri )
262
+ if ( parsed ?. subdomain ?. length > 0 ) {
263
+ uri = uri . replace ( `${ parsed . subdomain } .` , '' )
273
264
}
265
+ termQueries . push ( {
266
+ wildcard : { url : { value : `*${ uri } *` } }
267
+ } )
274
268
}
275
269
276
270
// if nym, items must contain nym
You can’t perform that action at this time.
0 commit comments