Skip to content

Commit

Permalink
fix handle unicode in vmess config with js-base64
Browse files Browse the repository at this point in the history
  • Loading branch information
seramo committed Sep 19, 2024
1 parent 17ec38d commit 2f67df8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ function replaceIPInConfig(inputConfig, ip) {
let result = '';

if (isVmess) {
let vmessConfig = JSON.parse(atob(inputConfig.replace('vmess://', '')));
let vmessConfig = JSON.parse(Base64.decode(inputConfig.replace('vmess://', '')));
vmessConfig.add = ipStr;
result = `vmess://${btoa(JSON.stringify(vmessConfig))}\n\n`;
result = `vmess://${Base64.encode(JSON.stringify(vmessConfig))}\n\n`;
} else {
ipStr = ip.kind() === 'ipv6' ? `[${ipStr}]` : ipStr;
const match = inputConfig.match(/^(vless:\/\/[^@]+)@([^:]+)(:.+)$/);
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ipaddr.js/2.0.1/ipaddr.min.js"></script>
<script src="assets/js/script.js?v=1.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/base64.min.js"></script>
<script src="assets/js/script.js?v=1.0.1"></script>
</body>
</html>

0 comments on commit 2f67df8

Please sign in to comment.