Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dart.googlesource.com-pub
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
dart.googlesource.com-pub
Commits
847c9189
Commit
847c9189
authored
8 years ago
by
Kevin Moore
Browse files
Options
Downloads
Patches
Plain Diff
Remove dependency on pkg/uuid
Use a home-rolled version
parent
b7864409
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/src/http.dart
+1
-2
1 addition, 2 deletions
lib/src/http.dart
lib/src/utils.dart
+23
-0
23 additions, 0 deletions
lib/src/utils.dart
pubspec.yaml
+0
-1
0 additions, 1 deletion
pubspec.yaml
test/utils_test.dart
+22
-0
22 additions, 0 deletions
test/utils_test.dart
with
46 additions
and
3 deletions
lib/src/http.dart
+
1
−
2
View file @
847c9189
...
...
@@ -10,7 +10,6 @@ import 'dart:io';
import
'package:http/http.dart'
as
http
;
import
'package:http_throttle/http_throttle.dart'
;
import
'package:stack_trace/stack_trace.dart'
;
import
'package:uuid/uuid.dart'
;
import
'command_runner.dart'
;
import
'io.dart'
;
...
...
@@ -31,7 +30,7 @@ final _CENSORED_FIELDS = const ['refresh_token', 'authorization'];
final
PUB_API_HEADERS
=
const
{
'Accept'
:
'application/vnd.pub.v2+json'
};
/// A unique ID to identify this particular invocation of pub.
final
_sessionId
=
new
Uuid
()
.
v4
()
as
String
;
final
_sessionId
=
createUuid
()
;
/// An HTTP client that transforms 40* errors and socket exceptions into more
/// user-friendly error messages.
...
...
This diff is collapsed.
Click to expand it.
lib/src/utils.dart
+
23
−
0
View file @
847c9189
...
...
@@ -824,3 +824,26 @@ void dataError(String message) => throw new DataException(message);
Iterable
/*<T>*/
combineIterables
/*<T>*/
(
Iterable
/*<T>*/
iter1
,
Iterable
/*<T>*/
iter2
)
=
>
iter1
.
toList
().
.
addAll
(
iter2
);
/// Returns a UUID in v4 format as a `String`.
///
/// If [bytes] is provided, it must be length 16 and have values between `0` and
/// `255` inclusive.
///
/// If [bytes] is not provided, it is generated using `Random.secure`.
String
createUuid
([
List
<
int
>
bytes
])
{
var
rnd
=
new
math
.
Random
.
secure
();
// See http://www.cryptosys.net/pki/uuid-rfc4122.html for notes
bytes
??=
new
List
<
int
>
.
generate
(
16
,
(
_
)
=
>
rnd
.
nextInt
(
256
));
bytes
[
6
]
=
(
bytes
[
6
]
&
0x0F
)
|
0x40
;
bytes
[
8
]
=
(
bytes
[
8
]
&
0x3f
)
|
0x80
;
var
chars
=
bytes
.
map
((
b
)
=
>
b
.
toRadixString
(
16
)
.
padLeft
(
2
,
'0'
))
.
join
()
.
toUpperCase
();
return
'
${chars.substring(0, 8)}
-
${chars.substring(8, 12)}
-'
'
${chars.substring(12, 16)}
-
${chars.substring(16, 20)}
-
${chars.substring(20, 32)}
'
;
}
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
0
−
1
View file @
847c9189
...
...
@@ -31,7 +31,6 @@ dependencies:
stack_trace
:
"
^1.0.0"
stream_channel
:
"
^1.4.0"
string_scanner
:
"
^1.0.0"
uuid
:
"
^0.5.0"
watcher
:
"
^0.9.2"
web_socket_channel
:
"
^1.0.0"
yaml
:
"
^2.0.0"
...
...
This diff is collapsed.
Click to expand it.
test/utils_test.dart
+
22
−
0
View file @
847c9189
...
...
@@ -102,4 +102,26 @@ b: {}"""));
expect
(
niceDuration
(
new
Duration
(
minutes:
1
)),
equals
(
"1:00.0s"
));
});
});
group
(
'uuid'
,
()
{
var
uuidRegexp
=
new
RegExp
(
"^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-"
r"[8-9A-B][0-9A-F]{3}-[0-9A-F]{12}$"
);
test
(
"min value is valid"
,
()
{
var
uuid
=
createUuid
(
new
List
<
int
>
.
filled
(
16
,
0
));
expect
(
uuid
,
matches
(
uuidRegexp
));
expect
(
uuid
,
"00000000-0000-4000-8000-000000000000"
);
});
test
(
"max value is valid"
,
()
{
var
uuid
=
createUuid
(
new
List
<
int
>
.
filled
(
16
,
255
));
expect
(
uuid
,
matches
(
uuidRegexp
));
expect
(
uuid
,
"FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"
);
});
test
(
"random values are valid"
,
()
{
for
(
var
i
=
0
;
i
<
100
;
i
++
)
{
var
uuid
=
createUuid
();
expect
(
uuid
,
matches
(
uuidRegexp
));
}
});
});
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment