Skip to content

Commit a8b3871

Browse files
committed
eliminate duplicate account problem
1 parent 8637ede commit a8b3871

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/publish/rsconnect/rsconnect.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ import { createTempContext } from "../../core/temp.ts";
3232
import { createBundle } from "./bundle.ts";
3333
import { completeMessage, withSpinner } from "../../core/console.ts";
3434
import { randomHex } from "../../core/random.ts";
35+
import { ensureTrailingSlash } from "../../core/path.ts";
3536

36-
export const kRSConnect = "rsconnect";
37-
const kRSConnectDescription = "RS Connect";
37+
export const kRSConnect = "connect";
38+
const kRSConnectDescription = "RStudio Connect";
3839

3940
export const kRSConnectServerVar = "CONNECT_SERVER";
4041
export const kRSConnectAuthTokenVar = "CONNECT_API_KEY";
@@ -90,7 +91,8 @@ function removeToken(token: AccountToken) {
9091
rsconnectProvider.name,
9192
readAccessTokens<Account>(rsconnectProvider.name)?.filter(
9293
(accessToken) => {
93-
return accessToken.username !== token.name;
94+
return accessToken.server !== token.server &&
95+
accessToken.username !== token.name;
9496
},
9597
) || [],
9698
);
@@ -101,7 +103,9 @@ async function authorizeToken(
101103
): Promise<AccountToken | undefined> {
102104
// ask for server (then validate that its actually a connect server
103105
// by sending a request without an auth token)
104-
let server = target?.url ? new URL(target.url).origin : undefined;
106+
let server = target?.url
107+
? ensureTrailingSlash(new URL(target.url).origin)
108+
: undefined;
105109
while (server === undefined) {
106110
// prompt for server
107111
server = await Input.prompt({

0 commit comments

Comments
 (0)