@@ -9,6 +9,7 @@ const querystring = require('querystring')
99const Transform = require ( 'readable-stream' ) . Transform
1010const pino = require ( 'pino-http' )
1111const pump = require ( 'pump' )
12+ const urlFormatLax = require ( 'url-format-lax' )
1213const args = require ( 'minimist' ) ( process . argv . slice ( 2 ) , {
1314 boolean : [ 'help' , 'verbose' ] ,
1415 default : {
@@ -72,7 +73,20 @@ db.upring.on('up', function () {
7273 throw err
7374 }
7475
75- console . log ( 'server listening on' , server . address ( ) )
76+ const address = server . address ( )
77+
78+ if ( address . address === '::' ) {
79+ address . host = '::1'
80+ } else {
81+ address . host = address . address
82+ }
83+
84+ const url = 'http://' + urlFormatLax ( address )
85+
86+ // expose the address
87+ db . upring . info . url = url
88+
89+ console . log ( 'server listening on' , url )
7690 } )
7791
7892 function handleGet ( req , res ) {
@@ -127,8 +141,12 @@ db.upring.on('up', function () {
127141 } )
128142
129143 req . on ( 'end' , function ( ) {
144+ var contentType = req . headers [ 'content-type' ]
145+ if ( ! contentType || contentType === 'application/x-www-form-urlencoded' ) {
146+ contentType = 'text/plain'
147+ }
130148 db . put ( req . url , {
131- contentType : req . headers [ 'content-type' ] ,
149+ contentType,
132150 value : str
133151 } , function ( err ) {
134152 if ( err ) {
0 commit comments