2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

github上でURLから始まるコミットメッセージを正しくリンクさせる

Posted at

リンクがおかしくなる

github上ではコミットメッセージからコミットのページへのリンクが自動で張られるが、メッセージ内容がURLで始まると正しくリンクされない。

例)
https://github.com/を参照 というメッセージの場合
https://github.com/horisakis/commit_message_url/commit/81df803f80cb99122aa4a8fd96e133cf42c823b2
こうなってほしいが

https://github.com/%E3%82%92%E5%8F%82%E7%85%A7
結果はこうなる

対処案

思いつく方法で色々試して見みた

シングルクオートでくくる

'https://github.com/'を参照
https://github.com/'%E3%82%92%E5%8F%82%E7%85%A7

ダブルクオートでくくる

"https://github.com/"を参照
https://github.com/%22%E3%82%92%E5%8F%82%E7%85%A7

スペースをあける

https://github.com/ を参照
[https://github.com/][1] [を参照][1]
[1]:https://github.com/horisakis/commit_message_url/commit/308a9f64c1974e65efdb2f67a912da677738a1bc

バッククオートでくくる

`https://github.com/`を参照
https://github.com/%60%E3%82%92%E5%8F%82%E7%85%A7

バックスラッシュでエスケープ

https\://github.com/を参照
https://github.com/horisakis/commit_message_url/commit/8036db15c220c3019df78071202da37f1aa4623c

特殊文字でエスケープ

https://github.com/を参照
https://github.com/horisakis/commit_message_url/commit/889628d3dc1c10a72906fbc17f8e037452cabcaf

まとめ

  • スペースをあける
  • バックスラッシュでエスケープ
  • 特殊文字でエスケープ

これらの場合に正しくリンクされた。
バックスラッシュと特殊文字の場合、エスケープ文字が表示されてしまうのでコピペして参照元に移動する際に文字列を修正する手間がかかる。
スペースを空けた場合、参照元URLから張られているリンクがコミットへのリンクになっているので注意が必要。

URLから始まるメッセージの場合はスペースを空けるのが無難か。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?