Permalink
Browse files

fix bug: generate format option UUID_FMT_SIV

  • Loading branch information...
1 parent d5657f0 commit 9021f22b08d23b14a2b2110eeb359aba39236d28 @mah0x211 committed May 30, 2011
Showing with 9 additions and 1 deletion.
  1. +5 −1 src/uuid.cc
  2. +4 −0 test/test.js
View
@@ -72,11 +72,15 @@ Handle<Value> generate( const Arguments &args )
}
else
{
- if( fmt == 0 ){
+ if( fmt == UUID_FMT_BIN ){
Buffer *retbuf = Buffer::New( len );
memcpy( Buffer::Data( retbuf ), gen, len );
retval = retbuf->handle_;
}
+ else if( fmt == UUID_FMT_SIV ){
+ len = strlen( (char*)gen );
+ retval = Encode( gen, len, UTF8 );
+ }
else{
retval = Encode( gen, len, UTF8 );
}
View
@@ -4,13 +4,17 @@ console.log( uuid );
console.log( uuid.version() );
console.log( 'v1' );
console.log( uuid.generate( uuid.fmt.STR, uuid.V1 ) );
+console.log( uuid.generate( uuid.fmt.SIV, uuid.V1 ) );
console.log( uuid.generate( uuid.fmt.TXT, uuid.V1 ) );
console.log( 'v3' );
console.log( uuid.generate( uuid.fmt.STR, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
+console.log( uuid.generate( uuid.fmt.SIV, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
console.log( uuid.generate( uuid.fmt.TXT, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
console.log( 'v4' );
console.log( uuid.generate( uuid.fmt.STR, uuid.V4 ) );
+console.log( uuid.generate( uuid.fmt.SIV, uuid.V4 ) );
console.log( uuid.generate( uuid.fmt.TXT, uuid.V4 ) );
console.log( 'v5' );
console.log( uuid.generate( uuid.fmt.STR, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
+console.log( uuid.generate( uuid.fmt.SIV, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
console.log( uuid.generate( uuid.fmt.TXT, uuid.V5, uuid.ns.url, 'http://example.com/' ) );

0 comments on commit 9021f22

Please sign in to comment.