我正试图在Discourse托管社区的徽章中添加一个领英分享按钮,我是该社区的管理员。
为此,我正尝试使用此插件出口。我在主题的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?