diff --git a/granary/bluesky.py b/granary/bluesky.py index 64f2e7e0..64a6f19f 100644 --- a/granary/bluesky.py +++ b/granary/bluesky.py @@ -536,7 +536,7 @@ def from_as1(obj, out_type=None, blobs=None, client=None): except (KeyError, ValueError, IndexError, TypeError): pass - name = tag.get('displayName') + name = tag.get('displayName', '').strip().lstrip('@#') if type == 'hashtag': facet['features'] = [{ '$type': 'app.bsky.richtext.facet#tag', diff --git a/granary/tests/test_bluesky.py b/granary/tests/test_bluesky.py index bbe2380c..c9671d32 100644 --- a/granary/tests/test_bluesky.py +++ b/granary/tests/test_bluesky.py @@ -785,6 +785,12 @@ def test_from_as1_tag_mention_html_content_guess_index(self): 'content': '
foo @you.com bar
', })) + def test_from_as1_tag_mention_at_char_html_content_guess_index(self): + note = copy.deepcopy(NOTE_AS_TAG_MENTION) + note['content'] = 'foo @you.com bar
' + note['tags'][0]['displayName'] = '@you.com' + self.assert_equals(POST_BSKY_FACET_MENTION, from_as1(note)) + def test_from_as1_drop_tag_with_start_past_content_length(self): note = copy.deepcopy(NOTE_AS_TAG_HASHTAG) note['tags'][0]['startIndex'] = len(note['content']) + 2