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

Get the correct username from the page URL, rather than extracting it from HTML #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nanos
Copy link

@nanos nanos commented Nov 25, 2022

That should be both more reliable, and stable (particularly when mastodon instances use custom themes, or a new mastodon version changes the HTML).

It also addresses #3: The reason this one isn't working, is because hachyderm doesn't always have the meta[property="profile:username"] element on the page.

I have left the previous mechanism to extract the username from the HTML in place, because it might be useful for instances that have changed the URL scheme (e.g. by removing the @ from the url) although I personally haven't seen any.

This should be more reliable than getting it from the page HTML.
@bramus
Copy link
Owner

bramus commented Nov 25, 2022

That actually was my first approach, but doesn’t work for instances that run on a subdomain.

For example: the profile URL for @[email protected] on their server is https://fediverse.zachleat.com/@zachleat. The instance runs on fedivers.zachleat.com which is a subdomain of zachleat.com. By parsing the data from the URL, their profile username would become @[email protected] which is wrong. It’s @[email protected]. This value can be found in the meta tag (if present).

Maybe this step could be included, but as fallback? First try the meta tag, then fall back to other possible locations.

@nanos
Copy link
Author

nanos commented Nov 25, 2022

LOL, yes, funnily enough I run my own instance on a subdomain, so should’ve definitely realised that, but I’ve set up an http redirect so it still works for me.

Will adjust the PR to do the checks the other way around: meta tag first, URL as fallback

This is because this works better if the the instance runs on a sub domain.
@nanos
Copy link
Author

nanos commented Nov 25, 2022

I've updated that now 👍

nanos added a commit to nanos/safari-mastodon-profile-redirect that referenced this pull request Nov 25, 2022
This is because this works better if the the instance runs on a sub domain.

See bramus/mastodon-redirector#5 (comment)
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.

2 participants