René's URL Explorer Experiment


Title: fix(files): download a markdown file as a zip only when it really has assets by waleedlatif1 · Pull Request #7009 · simstudioai/sim · GitHub

Open Graph Title: fix(files): download a markdown file as a zip only when it really has assets by waleedlatif1 · Pull Request #7009 · simstudioai/sim

X Title: fix(files): download a markdown file as a zip only when it really has assets by waleedlatif1 · Pull Request #7009 · simstudioai/sim

Description: Summary Downloading a markdown file returned a zip with an empty assets/ folder whenever the document merely mentioned an embed URL. Any document about the files API tripped it — an inline `/api/files/view/{id}` in prose was enough. Two independent causes, either of which reproduced it on its own: The detector regex-scanned raw document text, so prose, inline code spans, fenced samples, and links all counted as embedded assets. The export route picked zip-vs-markdown from the candidate count before resolving anything, so embeds that were missing, unreadable, or oversized still produced a zip. Detection now uses the markdown lexer and counts only real image embeds (![alt](src), reference images, and tags), so a mention can't masquerade as an attachment. Links are excluded — a link is navigated to, not displayed. The export format is now decided from what actually got bundled, so a document whose embeds don't resolve downloads as the document itself. Moved the document scan out of the copilot tool tree into lib/uploads/server/, where both consuming file routes already live, and dropped two pass-through wrappers. The src reader is now shared between the clipboard handlers and the scan instead of being defined twice. Walked tokens explicitly rather than via marked's walkTokens, which concatenates its callback's return value once per token and so costs O(n²) — a 254KB document measured 5.4s of blocked event loop versus 14ms. That path is reachable by anonymous public-share traffic, so this also removes an unauthenticated stall vector. The public share's referenced-by-doc gate tightens as a side effect: a file the document only links to or names in prose is no longer served through the share token. It was already bounded to the document's own workspace, and the viewer only ever requests embedded images, so nothing legitimate loses access. Type of Change Bug fix Testing New regression tests cover the reported case: a document that only mentions embed URLs, and a document whose embeds resolve to nothing. Each was verified to fail against the previous behavior and pass now. Also covered: reference-style images, inline and block , and that fenced/

 content is ignored.
bun run type-check, bun run lint, bun run check:api-validation, and the full bun run check:audits (33 audits) pass.
3,322 tests across the affected areas pass.

Checklist

 Code follows project style guidelines
 Self-reviewed my changes
 Tests added/updated and passing
 No new warnings introduced
 I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary Downloading a markdown file returned a zip with an empty assets/ folder whenever the document merely mentioned an embed URL. Any document about the files API tripped it — an inline `/api/f...

X Description: Summary Downloading a markdown file returned a zip with an empty assets/ folder whenever the document merely mentioned an embed URL. Any document about the files API tripped it — an inline `/api/f...

Opengraph URL: https://github.com/simstudioai/sim/pull/7009

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:208bd8cc-1404-ecc3-c4ac-3ac27497468a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8CBA:72699:B5AD83:FF391F:6AFB7991
html-safe-nonceb4ab3be4238667180b357243731381ada14598effc200bb9252b2caf50d62435
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0JBOjcyNjk5OkI1QUQ4MzpGRjM5MUY6NkFGQjc5OTEiLCJ2aXNpdG9yX2lkIjoiMjkzODQ2NjAyNjk4NDc5ODYwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac09671b2d65e585b6a9a1eb9af2983aef17c34e4df88e3e64a9e0f99015eb735c
hovercard-subject-tagpull_request:4341831397
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7009/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Downloading a markdown file returned a zip with an empty assets/ folder whenever the document merely mentioned an embed URL. Any document about the files API tripped it — an inline `/api/f...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0e29e7974fdda2feeaf5c891efd4b23b0734b23480232b62c7bdef13f40b5b48
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2e8872b770cc4d5d0cc1f2026afab747a268e2ce
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/7009/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F7009%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F7009%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/7009/files
Reloadhttps://github.com/simstudioai/sim/pull/7009/files
Reloadhttps://github.com/simstudioai/sim/pull/7009/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests202 (202)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/file-zip-downloadhttps://github.com/simstudioai/sim/tree/fix/file-zip-download
Conversation 24 https://github.com/simstudioai/sim/pull/7009
Commits 4 https://github.com/simstudioai/sim/pull/7009/commits
Checks 29 https://github.com/simstudioai/sim/pull/7009/checks
Files changed https://github.com/simstudioai/sim/pull/7009/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
fix(files): download a markdown file as a zip only when it really has assets https://github.com/simstudioai/sim/pull/7009/files#top
Show all changes 4 commits https://github.com/simstudioai/sim/pull/7009/files
ed78cda fix(files): download a markdown file as a zip only when it really has… waleedlatif1 Aug 23, 2026 https://github.com/simstudioai/sim/pull/7009/commits/ed78cda9ef8547ce43223a9b64aed88b5909ca7c
10bb0e7 fix(files): keep an embed id spelled as the document spells it waleedlatif1 Aug 23, 2026 https://github.com/simstudioai/sim/pull/7009/commits/10bb0e73cbb3c056d53501961bf6c31df5422805
f346f5c fix(files): resolve an export asset by its stored id, rewrite by its … waleedlatif1 Aug 23, 2026 https://github.com/simstudioai/sim/pull/7009/commits/f346f5ce514647208ba7e0e0d57f5a560471c8a0
c76fc77 fix(files): resolve an embed by its stored id wherever one is read fr… waleedlatif1 Aug 23, 2026 https://github.com/simstudioai/sim/pull/7009/commits/c76fc77f6c10966171bc840c2d4cd5e96a81b3be
Clear filters https://github.com/simstudioai/sim/pull/7009/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
route.test.ts https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
route.ts https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
route.ts https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
image-paste.test.ts https://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
image-paste.ts https://github.com/simstudioai/sim/pull/7009/files#diff-87eb80f15520439634b375c322903f3004a3c9a4c7dfea250326f34e4352c3a6
rich-markdown-editor.tsx https://github.com/simstudioai/sim/pull/7009/files#diff-6ddf250be25a5febc97c8c4a2e0f9e93b869e674efbb9bd43358137571ddc05a
embedded-image-refs.test.ts https://github.com/simstudioai/sim/pull/7009/files#diff-d0a758f7f2791a8f1052f5ea3c05b35241d27f2398bcaf4695554e2e38b1e061
embedded-image-refs.ts https://github.com/simstudioai/sim/pull/7009/files#diff-cf5d3fa8bd2265bf9d3fbe5de5ca2bb1abfc24d9490cb1acf33b12e4375aa8b0
embedded-image-refs.test.ts https://github.com/simstudioai/sim/pull/7009/files#diff-f7eadaab547b101cb0a2f39b302276b242b7392ffb7e181741f03d23721cea72
embedded-image-refs.ts https://github.com/simstudioai/sim/pull/7009/files#diff-c4f00b90a27b4d5d9763cd2aaf4fafdcac5f21134acb3276bb8ecc17bf4ca938
embedded-image-ref.test.ts https://github.com/simstudioai/sim/pull/7009/files#diff-b7db7b080202d4906f7ca3dbd7fe07cbb295824bcfb2ee9ba9b199a1083fa5da
embedded-image-ref.ts https://github.com/simstudioai/sim/pull/7009/files#diff-fe8ca18e5048aad2212ea80c1a2e64ab5ddbae82369e72af17be15473c21a442
apps/sim/app/api/files/export/[id]/route.test.tshttps://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
View file https://github.com/simstudioai/sim/blob/c76fc77f6c10966171bc840c2d4cd5e96a81b3be/apps/sim/app/api/files/export/%5Bid%5D/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7009/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
https://github.com/simstudioai/sim/pull/7009/files#diff-cd591b0264baee291a708160d8122658c9999b7e32f09d74b0908bcd874e96fb
apps/sim/app/api/files/export/[id]/route.tshttps://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
View file https://github.com/simstudioai/sim/blob/c76fc77f6c10966171bc840c2d4cd5e96a81b3be/apps/sim/app/api/files/export/%5Bid%5D/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7009/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
https://github.com/simstudioai/sim/pull/7009/files#diff-c1d6d66f4d090c56d722fc0d20b0c02464e9d96959db92ecea1553be66affa6a
apps/sim/app/api/files/public/[token]/inline/route.tshttps://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
View file https://github.com/simstudioai/sim/blob/c76fc77f6c10966171bc840c2d4cd5e96a81b3be/apps/sim/app/api/files/public/%5Btoken%5D/inline/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7009/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
https://github.com/simstudioai/sim/pull/7009/files#diff-72139ed47a6fe9576216eb2f23fdfb0698cd9c5b31f0ff0b30e8238a49521860
...space/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image-paste.test.tshttps://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
View file https://github.com/simstudioai/sim/blob/c76fc77f6c10966171bc840c2d4cd5e96a81b3be/apps/sim/app/workspace/%5BworkspaceId%5D/files/components/file-viewer/rich-markdown-editor/image-paste.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7009/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
https://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
https://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
https://github.com/simstudioai/sim/pull/7009/files#diff-ccd2ec6fcd595115b0e2d1aa420d0631929414ce475ffa6f30787759cb31fb02
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7009/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.