Discourse-hosted コミュニティの管理者は、バッジに LinkedIn シェアボタンを追加しようとしています。
そのために、このプラグインアウトレット を使用しようとしています。次のコードをテーマの head セクションに含めました。
<script type='text/x-handlebars' data-template-name='/connectors/badge-contents-top/linkedin-button'>
<a href="https://www.linkedin.com/profile/add?certUrl=https://community.my_community.io{{@outletArgs.url}}" class="linkedin-share-button">
<img src="https://download.linkedin.com/desktop/add2profile/buttons/en_US.png " alt="LinkedIn Add to Profile button">
</a>
</script>
href 属性に注意してください: https://www.linkedin.com/profile/add?certUrl=https://community.my_community.io/{{@outletArgs.url}}。
@outletArgs.url の値は https://community.my_community.io/badges/<badge_id>/<badge_name>?username=<username> のようになります。username=<username> の部分に注目したいと思います。
URL はエンコードされておらず、等号は文字通り渡されるため、ブラウザが https://www.linkedin.com/profile/add?certUrl=https://community.my_community.io/https://community.my_community.io/badges/<badge_id>/<badge_name>?username=<username> を処理すると、=<username> は無視されます。
ここで URL をエンコードするにはどうすればよいですか?