nextcloud/cypress/support/utils/randomString.ts
Ferdinand Thiessen 1082dee5a4
chore: migrate Cypress to @nextcloud/e2e-test-server
- chore: use vite preprocessor for Cypress

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2025-10-22 11:57:17 +02:00

19 lines
610 B
TypeScript

/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
export function randomString(length: number) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
const alphaNumeric = characters + '0123456789'
let result = ''
for (let i = 0; i < length; i++) {
// Ensure the first character is alphabetic
if (i === 0) {
result += characters.charAt(Math.floor(Math.random() * characters.length))
continue
}
result += alphaNumeric.charAt(Math.floor(Math.random() * alphaNumeric.length))
}
return result
}