crawlforge-extractors 1.2.2 → 1.2.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/templates.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crawlforge-extractors",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Extraction logic shared by the CrawlForge MCP server and REST API — scrape templates, charset-correct capped body reading, and structural fingerprinting. One implementation, so the two surfaces cannot drift apart.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/templates.js CHANGED
@@ -220,6 +220,18 @@ function githubLicense(license) {
220
220
  return (spdx && spdx !== 'NOASSERTION' ? spdx : license.name) || null;
221
221
  }
222
222
 
223
+ /**
224
+ * og:description is never just the About text. GitHub appends "Contribute to
225
+ * owner/repo development by creating an account on GitHub." to it, and that
226
+ * sentence is the *whole* value on a repo with no description at all. Strip
227
+ * it; whatever remains is the description, and nothing remaining means the
228
+ * repo has none.
229
+ */
230
+ function githubOgDescription($) {
231
+ const og = attr($, 'meta[property="og:description"]', 'content') || '';
232
+ return tidy(og.replace(/\s*Contribute to \S+ development by creating an account on GitHub\.?/, ''));
233
+ }
234
+
223
235
  /**
224
236
  * Repo tab counters stamp the exact number in title= ("5,102") and an
225
237
  * abbreviated text ("5.1k"); a counter with nothing to show stamps
@@ -391,7 +403,12 @@ export const TEMPLATES = [
391
403
  const about = githubSidebarAbout($);
392
404
  return {
393
405
  name: text($, 'strong[itemprop="name"] a') || text($, '.repository-content h1'),
394
- description: attr($, 'meta[property="og:description"]', 'content') || text($, 'p.f4.my-3'),
406
+ // Like homepage: when the sidebar payload is present it is
407
+ // authoritative, so a repo that set no description reports null
408
+ // rather than GitHub's "Contribute to ..." boilerplate.
409
+ description: about
410
+ ? tidy(about.description)
411
+ : tidy(text($, 'p.f4.my-3')) || githubOgDescription($),
395
412
  stars: text($, '#repo-stars-counter-star') || text($, '[aria-label*="stargazers"]'),
396
413
  forks: text($, '#repo-network-counter') || text($, '[aria-label*="forks"]'),
397
414
  // React (logged-out) layout has no watchers aria-label; the count is