Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(www): support server name on dynamic keys #1483

Merged
merged 8 commits into from
Nov 30, 2022
8 changes: 7 additions & 1 deletion src/www/app/outline_server_repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ function isDynamicAccessKey(accessKey: string): boolean {
// (Currenly done by setting the hash on the URI)
function serverNameFromAccessKey(accessKey: string): string {
if (isDynamicAccessKey(accessKey)) {
return new URL(accessKey.replace(/^ssconf:\/\//, 'https://')).hostname;
const {hostname, hash} = new URL(accessKey.replace(/^ssconf:\/\//, 'https://'));

if (hash && hash !== '#') {
return decodeURIComponent(hash.slice(1));
daniellacosse marked this conversation as resolved.
Show resolved Hide resolved
}

return hostname;
}

return SHADOWSOCKS_URI.parse(accessKey).tag.data;
daniellacosse marked this conversation as resolved.
Show resolved Hide resolved
Expand Down