mirror of
https://github.com/bitinflow/server.git
synced 2026-03-13 13:35:53 +00:00
Generate human readable IDs for client URLs (#77)
Based on @FranzSkuffka's suggested enhancement in PR 207 on localtunnel/localtunnel (https://github.com/localtunnel/localtunnel/pull/207), this PR uses the "human-readable-ids" package to generate IDs of the form "adjective-noun-number". These IDs are easier to remember and arguably more useful in testing since they can be retyped without copying and pasting. Some sample IDs generated by this package are: * heavy-puma-90 * grump-walrus-64 * purple-starfish-58 * nasty-seahorse-9
This commit is contained in:
committed by
Roman Shtylman
parent
d7852a3dd1
commit
b1c296a409
@@ -4,8 +4,8 @@ import Proxy from './Proxy';
|
||||
import on_finished from 'on-finished';
|
||||
import http from 'http';
|
||||
import pump from 'pump';
|
||||
import { hri } from "human-readable-ids";
|
||||
|
||||
import rand_id from './rand_id';
|
||||
import BindingAgent from './BindingAgent';
|
||||
|
||||
const NoOp = () => {};
|
||||
@@ -36,7 +36,7 @@ class ClientManager {
|
||||
|
||||
// can't ask for id already is use
|
||||
if (clients[id]) {
|
||||
id = rand_id();
|
||||
id = hri.random();
|
||||
}
|
||||
|
||||
const popt = {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// all url safe
|
||||
// can't use uppercase because hostnames are lowercased
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
export default function rand_id() {
|
||||
let randomstring = '';
|
||||
for (var i=0; i<10; ++i) {
|
||||
const rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars[rnum];
|
||||
}
|
||||
|
||||
return randomstring;
|
||||
}
|
||||
Reference in New Issue
Block a user