Skip to content

Commit 325d6f5

Browse files
committed
fix(cloud_auth): Allow dashes in routes
1 parent 2f08a2f commit 325d6f5

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

services/celest_cloud_auth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.1
2+
3+
- fix: Allow dashes in routes
4+
15
## 0.3.0
26

37
- feat!: Make database modular

services/celest_cloud_auth/lib/src/model/route.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,19 @@ final class RouteWildcard extends RouteSegment {
210210
/// Not a standard, but a generally accepted upper bound on reasonable URLs.
211211
static const int _maxUrlLength = 2048;
212212

213+
/// Allowed characters in a URL path segment.
214+
// TODO(dnys1): Handle percent-encoded characters.
215+
// https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L241
216+
static final Parser<String> _validChar = pattern('-_.~0-9a-zA-Z');
217+
213218
late final Parser<String> _parser = greedy
214219
// The syntax `**` matches zero or more URL path segments
215-
? (word() | char('/'))
220+
? (_validChar | char('/'))
216221
.repeatLazy(endOfInput(), 0, _maxUrlLength)
217222
.flatten('**')
218223

219224
// The syntax `*` matches a single URL path segment.
220-
: word().plus().flatten('*');
225+
: _validChar.plus().flatten('*');
221226

222227
@override
223228
Result<String> parseOn(Context context) {

services/celest_cloud_auth/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: celest_cloud_auth
22
description: A Dart-native authentication and authorization service built on Celest, Cedar, and SQLite.
3-
version: 0.3.0
3+
version: 0.3.1
44
homepage: https://celest.dev
55
repository: https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth
66

services/celest_cloud_auth/test/model/route_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,30 @@ final _testCases = <_TestCase>[
246246
),
247247
],
248248
),
249+
(
250+
route: '/v1alpha1/{name=organizations/*/projects/*}',
251+
expectedSegments: [
252+
RouteLiteral('v1alpha1'),
253+
RouteParameter(
254+
variable: 'name',
255+
segments: [
256+
RouteLiteral('organizations'),
257+
RouteWildcard(greedy: false),
258+
RouteLiteral('projects'),
259+
RouteWildcard(greedy: false),
260+
],
261+
),
262+
],
263+
expectedVerb: null,
264+
matchTests: [
265+
(
266+
route: '/v1alpha1/organizations/org_1234/projects/my-project',
267+
expected: {
268+
'name': 'organizations/org_1234/projects/my-project',
269+
},
270+
),
271+
],
272+
),
249273
(
250274
route: '/v1alpha1/auth/{name=organizations/*/users/*}',
251275
expectedSegments: [

0 commit comments

Comments
 (0)