Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bsky short link service #4542

Merged
merged 12 commits into from
Jun 21, 2024
Merged

Bsky short link service #4542

merged 12 commits into from
Jun 21, 2024

Conversation

devinivy
Copy link
Contributor

@devinivy devinivy commented Jun 17, 2024

Included here is a postgres-backed node service for generating short links.

API Usage

POST /link

Generates a short link for a given path. A given path always produces the same short link, up to some path normalization. Currently only paths to starter packs which contain the actor's DID (rather than handle) are supported, e.g. /start/did:plc:example/3kv5iwj3csz2p.
Request

{ "path": "/start/did:plc:example/3kv5iwj3csz2p" }

Response

{ "url": "https://link.bsky.app/6H8uqD" }

GET /:linkId

This endpoint represents the short link itself. It generates a 301 permanent redirect to the original link. Query parameters are preserved. If the link id is not familiar, a temporary 303 redirect to the app's homepage is served.

Copy link

render bot commented Jun 17, 2024

Copy link

github-actions bot commented Jun 17, 2024

Old size New size Diff
6.3 MB 6.3 MB 0 B (0.00%)

@pfrazee pfrazee assigned pfrazee and unassigned pfrazee Jun 20, 2024
Comment on lines +314 to +318
if req.Method == "GET" &&
strings.LastIndex(strings.TrimRight(req.URL.Path, "/"), "/") == 0 && // top-level path
!strings.HasPrefix(req.URL.Path, "/_") { // e.g. /_health endpoint
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to verify, we're okay with these not having some identifying prefix right? ik that came up in discussions though we definitely didn't want it to be a path like /i/abcdef

Copy link
Collaborator

@pfrazee pfrazee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just gave it a glance without much opinion, seems good

@pfrazee pfrazee removed their assignment Jun 20, 2024
@devinivy devinivy merged commit 55812b0 into main Jun 21, 2024
8 checks passed
@devinivy devinivy deleted the divy/bskylink branch June 21, 2024 16:41
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.

3 participants