Skip to content

日本語交じりのURLの一部が自動リンクの対象にならない #57

@fvh-P

Description

@fvh-P

問題は既知ですが調査結果を共有しておきます。

good or bad 入力内容 自動リンク処理結果
👍 https://www.yahoo.co.jp/ yahoo.co.jp/
👍 http://日本語.jp/about 日本語.jp/about
👎 http://dic.nicovideo.jp/a/アイドルマスター dic.nicovideo.jp/a/アイドルマスター

ホスト名に使われている日本語(おそらく非ASCII文字)はPunycodeで符号化されるらしく、有効です。
パス名に使われている日本語は無効になります。パス名を頭から読んでいって最初に非ASCII文字が出てきたところでURLとしての解釈が終わります。

Statusに投げられたプレーンテキストの処理にはtwitter-textのExtractorが使われているため、twitter-textの仕様だろうと思われます。

twitext

しかし、面白いことに(?)LinkCardは正常に取得できています。
linkcard

FetchLinkCardServiceによれば、LinkCardを生成する際のURL認識は正規表現で行われているようです。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions