This repository was archived by the owner on May 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 51
51
"jshint" : " 2.9.5" ,
52
52
"spring-flo" : " 0.8.0" ,
53
53
"ng-busy" : " 1.4.4" ,
54
- "rxjs-compat" : " ^6.2.1"
54
+ "rxjs-compat" : " ^6.2.1" ,
55
+ "uuid" : " 3.3.2"
55
56
},
56
57
"devDependencies" : {
57
58
"@angular/compiler-cli" : " 6.0.7" ,
62
63
"@types/jasmine" : " 2.8.8" ,
63
64
"@types/jasminewd2" : " 2.0.3" ,
64
65
"@types/node" : " 8.9.5" ,
66
+ "@types/uuid" : " 3.4.3" ,
65
67
"codelyzer" : " 4.2.1" ,
66
68
"jasmine-core" : " 2.99.1" ,
67
69
"jasmine-spec-reporter" : " 4.2.1" ,
Original file line number Diff line number Diff line change 1
1
import { Injectable } from '@angular/core' ;
2
2
import { LocalStorageService } from 'angular-2-local-storage' ;
3
3
4
+ import * as uuidv4 from 'uuid/v4' ;
5
+
4
6
/**
5
- * A service for global logs .
7
+ * A service for create group route .
6
8
*
7
9
* @author Damien Vitrac
8
10
*/
@@ -12,11 +14,16 @@ export class GroupRouteService {
12
14
constructor ( private localStorageService : LocalStorageService ) {
13
15
}
14
16
17
+ /**
18
+ * Create an unique UUID
19
+ * Format:
20
+ * 6ba7b810-9dad-11d1-80b4-00c04fd430c8
21
+ *
22
+ * @param args
23
+ * @returns {string }
24
+ */
15
25
create ( args ) : string {
16
- const key = `group-${ 'xxxxx-xxxxx-xxxxx-xxxxx' . replace ( / [ x y ] / g, function ( c ) {
17
- const r = Math . random ( ) * 16 | 0 , v = c === 'x' ? r : ( r & 0x3 | 0x8 ) ;
18
- return v . toString ( 16 ) ;
19
- } ) } `;
26
+ const key = 'group-' + uuidv4 ( ) ;
20
27
this . localStorageService . set ( key , args ) ;
21
28
return key ;
22
29
}
@@ -26,7 +33,8 @@ export class GroupRouteService {
26
33
if ( ! str . startsWith ( 'group-' ) ) {
27
34
return false ;
28
35
}
29
- if ( str . length !== 29 || str [ 11 ] !== '-' || str [ 17 ] !== '-' || str [ 23 ] !== '-' ) {
36
+ const g = `group-` . length ;
37
+ if ( str . length !== ( 36 + g ) || str [ ( 8 + g ) ] !== '-' || str [ ( 13 + g ) ] !== '-' || str [ ( 18 + g ) ] !== '-' || str [ ( 23 + g ) ] !== '-' ) {
30
38
return false ;
31
39
}
32
40
return true ;
Original file line number Diff line number Diff line change
1
+ import * as uuidv4 from 'uuid/v4' ;
2
+
1
3
/**
2
4
* A service for group route.
3
5
*
@@ -12,10 +14,7 @@ export class MockGroupRouteService {
12
14
}
13
15
14
16
create ( args ) : string {
15
- const key = `group-${ 'xxxxx-xxxxx-xxxxx-xxxxx' . replace ( / [ x y ] / g, function ( c ) {
16
- const r = Math . random ( ) * 16 | 0 , v = c === 'x' ? r : ( r & 0x3 | 0x8 ) ;
17
- return v . toString ( 16 ) ;
18
- } ) } `;
17
+ const key = 'group-' + uuidv4 ( ) ;
19
18
this . _group [ key ] = args ;
20
19
this . last = {
21
20
key : key ,
@@ -29,7 +28,8 @@ export class MockGroupRouteService {
29
28
if ( ! str . startsWith ( 'group-' ) ) {
30
29
return false ;
31
30
}
32
- if ( str . length !== 29 || str [ 11 ] !== '-' || str [ 17 ] !== '-' || str [ 23 ] !== '-' ) {
31
+ const g = `group-` . length ;
32
+ if ( str . length !== ( 36 + g ) || str [ ( 8 + g ) ] !== '-' || str [ ( 13 + g ) ] !== '-' || str [ ( 18 + g ) ] !== '-' || str [ ( 23 + g ) ] !== '-' ) {
33
33
return false ;
34
34
}
35
35
return true ;
You can’t perform that action at this time.
0 commit comments