Changeset

2665:cfb7936ff61f

mod_http_upload: Use the new util.id if available (in 0.10+)
author Kim Alvefur <zash@zash.se>
date Tue, 04 Apr 2017 00:06:19 +0200
parents 2664:5b97b04e9d1b
children 2666:99c0b1bacdcd
files mod_http_upload/mod_http_upload.lua
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Mon Apr 03 16:15:15 2017 +0200
+++ b/mod_http_upload/mod_http_upload.lua	Tue Apr 04 00:06:19 2017 +0200
@@ -16,14 +16,10 @@
 local t_concat = table.concat;
 local t_insert = table.insert;
 local s_upper = string.upper;
-local have_random, random = pcall(require, "util.random"); -- Only available in 0.10+
+local have_id, id = pcall(require, "util.id"); -- Only available in 0.10+
 local uuid = require"util.uuid".generate;
-if have_random then
-	local b64 = require "util.encodings".base64.encode;
-	local b64url = { ['+'] = '-', ['/'] = '_', ['='] = '' };
-	function uuid()
-		return (b64(random.bytes(8)):gsub("[+/=]", b64url));
-	end
+if have_id then
+	uuid = id.medium();
 end
 
 local function join_path(...) -- COMPAT util.path was added in 0.10