···2323 /** Maximum collision resolution attempts */
2424 MAX_COLLISION_ATTEMPTS: 20,
25252626- /** Base70 character set (includes special characters) */
2727- BASE62_CHARS: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+=_-?<>'
2626+ /** character set */
2727+ CHARS: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
2828} as const;
29293030/**
+9-9
src/lib/utils/encoding.ts
···55import { SHORTCODE } from '$lib/constants';
6677/**
88- * Base70 characters used for encoding (0-9, a-z, A-Z, and special chars: +=_-?<>)
88+ * characters used for encoding (0-9, a-z, A-Z)
99 */
1010-const BASE_CHARS = SHORTCODE.BASE62_CHARS;
1010+const BASE_CHARS = SHORTCODE.CHARS;
1111const BASE = BASE_CHARS.length;
12121313/**
···2929 * Encodes a number to base string
3030 * @param num - Number to encode
3131 * @param length - Target length of the encoded string
3232- * @returns Base70 encoded string
3232+ * @returns encoded string
3333 */
3434function toBase(num: number, length: number): string {
3535 let encoded = '';
···4141}
42424343/**
4444- * Encodes a URL to a short base70 string
4545- * Uses a deterministic hash-to-base70 encoding
4444+ * Encodes a URL to a short string
4545+ * Uses a deterministic hash encoding
4646 *
4747 * @param url - URL to encode
4848 * @param length - Target length of the shortcode (default: 6)
4949- * @returns Short base70 encoded string
4949+ * @returns Short encoded string
5050 *
5151 * @example
5252 * encodeUrl('https://github.com/user') // Returns something like 'a3k9zx'
···5757}
58585959/**
6060- * Validates if a string is a valid base70 shortcode
6060+ * Validates if a string is a valid shortcode
6161 * @param code - String to validate
6262 * @returns True if the code contains only valid characters
6363 */
6464export function isValidShortcode(code: string): boolean {
6565- return /^[0-9a-zA-Z+=_\-?<>]+$/.test(code);
6565+ return /^[0-9a-zA-Z]+$/.test(code);
6666}
67676868/**
···7171 * @returns Number of possible combinations
7272 *
7373 * @example
7474- * getMaxCombinations(6) // Returns 117649000000 (70^6)
7474+ * getMaxCombinations(6)
7575 */
7676export function getMaxCombinations(length: number): number {
7777 return Math.pow(BASE, length);