Skip to content

Conversation

@mkyutani
Copy link
Collaborator

Problem Description

Fixes #16

When executing ssky get --long on posts containing URLs created from the Bluesky GUI, the URLs in the post text are displayed in a truncated state.

Root Cause

The issue was caused by the PostDataList.Item.long() method displaying the raw post.record.text which contains truncated URLs, while the complete URL information is stored in post.record.facets but was not being processed.

Solution

Added a new method _process_urls_from_facets() that:

  • Extracts complete URLs from facets information
  • Replaces truncated URLs in the text with complete URLs using UTF-8 byte-level processing
  • Only processes URL links (ignores mentions and tags as requested)

Changes Made

  1. New Method: _process_urls_from_facets()

    • Processes facets to restore complete URLs
    • Uses UTF-8 byte-level indexing for accurate replacement
    • Handles multiple URLs in reverse order to prevent index shifting
  2. Modified Methods:

    • text_only(): Now processes URLs from facets
    • long(): Now processes URLs from facets
    • simple_json(): Now processes URLs from facets

Testing

Tested with the sample URI from issue #16:

ssky get "at://did:plc:g5olzasrsnnfbz3vabzhgqlh/app.bsky.feed.post/3loaq77q5fk2u::bafyreig2sba4eftvc6cqunmzhwlxpwwi6ps7bwtbq3wxqmwkemyp2cdfs4" -L

Before:

www.digital.go.jp/assets/conte...

After:

https://www.digital.go.jp/assets/contents/node/basic_page/field_ref_resources/c30d3c8e-17bf-4107-a1ab-b00c2f4c74ef/ae6b13df/20250425_base-registry-advisory-board_outline_05.pdf

Impact

  • ✅ URLs are now displayed completely in --long format
  • ✅ URLs are now displayed completely in --text format
  • ✅ URLs are now displayed completely in --simple-json format
  • ✅ No impact on posts without URLs
  • ✅ No impact on mentions or tags (intentionally not processed)

Backward Compatibility

This change is fully backward compatible and only improves the display of URLs without affecting any existing functionality.

@mkyutani mkyutani merged commit 9cad152 into simpleskyclient:main Jun 16, 2025
@mkyutani mkyutani deleted the 16-fix-url-truncation branch July 1, 2025 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: URL in post text is truncated when using --long option

1 participant