pi-wsearch 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/urls.ts CHANGED
@@ -13,6 +13,12 @@ const JUNK_HOSTS = [
13
13
  'twitch.tv',
14
14
  '9gag.com',
15
15
  'buzzfeed.com',
16
+ 'twiscan.com',
17
+ 'twstalker.com',
18
+ 'unrollnow.com',
19
+ 'threadreaderapp.com',
20
+ 'nitter.net',
21
+ 'upd.dev',
16
22
  ];
17
23
  const JUNK_TLDS = new Set(['xyz', 'top', 'loan', 'click', 'work', 'gq', 'icu', 'rest', 'cyou']);
18
24
 
@@ -53,7 +59,11 @@ export function normalizeUrl(raw: string): string {
53
59
  const pairs = Array.from(u.searchParams.entries()).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
54
60
  const q = pairs.map(([k, v]) => `${k}=${v}`).join('&');
55
61
  const port = u.port ? `:${u.port}` : '';
56
- return `${u.protocol}//${host}${port}${u.pathname.replace(/\/+$/, '')}${q ? '?' + q : ''}`;
62
+ const path = u.pathname
63
+ .replace(/\/{2,}/g, '/')
64
+ .replace(/\/+$/, '')
65
+ .toLowerCase();
66
+ return `${u.protocol}//${host}${port}${path}${q ? '?' + q : ''}`;
57
67
  } catch {
58
68
  return raw.toLowerCase();
59
69
  }
@@ -64,5 +74,14 @@ export function isJunk(raw: string): boolean {
64
74
  if (JUNK_HOSTS.some((j) => host === j || host.endsWith('.' + j))) return true;
65
75
  const tld = host.split('.').pop() ?? '';
66
76
  if (JUNK_TLDS.has(tld)) return true;
77
+ if (/\/(?:status|thread)\/\d+(?:[/?#]|$)/i.test(pathOf(raw))) return true;
67
78
  return false;
68
79
  }
80
+
81
+ function pathOf(raw: string): string {
82
+ try {
83
+ return new URL(raw).pathname;
84
+ } catch {
85
+ return '';
86
+ }
87
+ }
package/justfile DELETED
@@ -1,31 +0,0 @@
1
- export PATH := "node_modules/.bin:" + env_var_or_default("PATH", "")
2
-
3
- default: check
4
-
5
- check: lint format-check typecheck knip test
6
-
7
- lint:
8
- oxlint
9
-
10
- format:
11
- oxfmt
12
-
13
- format-check:
14
- oxfmt --check
15
-
16
- typecheck:
17
- tsc --noEmit
18
-
19
- knip:
20
- knip
21
-
22
- coverage:
23
- bun test --jobs 1 test/ --coverage
24
-
25
- test:
26
- bun test --jobs 1 test/
27
-
28
- install:
29
- mkdir -p $HOME/.pi/agent/extensions/pi-wsearch/src
30
- cp index.ts $HOME/.pi/agent/extensions/pi-wsearch/
31
- cp src/*.ts $HOME/.pi/agent/extensions/pi-wsearch/src/