Skip to content

Commit

Permalink
refactor: move getNonce to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ruifigueira committed Jul 25, 2024
1 parent 78b44c3 commit 1fc9575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/settingsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DisposableBase } from './disposableBase';
import type { ReusedBrowser } from './reusedBrowser';
import type { SettingsModel } from './settingsModel';
import type { TestModelCollection } from './testModel';
import { getNonce } from './utils';
import * as vscodeTypes from './vscodeTypes';
import path from 'path';

Expand Down Expand Up @@ -387,11 +388,3 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur
</script>
</html>`;
}

function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,11 @@ export async function getPlaywrightInfo(vscode: vscodeTypes.VSCode, workspaceFol
cliOverride = path.join(workspaceFolder, 'tests/playwright-test/stable-test-runner/node_modules/@playwright/test/cli.js');
return { cli: cliOverride, version };
}

export function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}

0 comments on commit 1fc9575

Please sign in to comment.