Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## 1.1.0-wip
## 2.0.0-wip

- Require Dart 3.1.0 or greater.
- No longer explicitly name the `matchers.dart` library as `uri.matchers`.
- Drop support for the `matchers` library, so that we can drop the dependency
on `matcher`.
- If you need this, please file a request for a new package to be published
with just the matcher functionality.
- Drop the dependency on `quiver`.

## 1.0.0

Expand Down
45 changes: 0 additions & 45 deletions lib/matchers.dart

This file was deleted.

18 changes: 13 additions & 5 deletions lib/src/uri_pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:quiver/collection.dart' show mapsEqual;
import 'package:quiver/core.dart' show hash4;

/// An interface for objects that match [Uri]s.
abstract class UriPattern {
/// Returns `true` if [uri] is matched by this pattern.
Expand Down Expand Up @@ -45,9 +42,20 @@ class UriMatch {
other is UriMatch &&
pattern == other.pattern &&
input == other.input &&
mapsEqual(parameters, other.parameters) &&
parameters.equals(other.parameters) &&
rest == other.rest;

@override
int get hashCode => hash4(pattern, input, parameters.toString(), rest);
int get hashCode => Object.hash(pattern, input, parameters.toString(), rest);
}

extension on Map<String, String?> {
bool equals(Map<String, String?> other) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use collectionEquals from dart:collection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would have to add a dependency on package:collection to get that afaik, and we only need shallow equality which is trivial to implement here.

if (length != other.length) return false;
for (var entry in entries) {
if (!other.containsKey(entry.key)) return false;
if (other[entry.key] != entry.value) return false;
}
return true;
}
}
8 changes: 3 additions & 5 deletions lib/src/uri_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import 'dart:collection' show UnmodifiableListView;

import 'package:quiver/pattern.dart' show escapeRegex;

import 'encoding.dart';
import 'uri_builder.dart';
import 'uri_pattern.dart';
Expand Down Expand Up @@ -371,7 +369,7 @@ class _Compiler {
for (var i = 0; i < subparts.length; i++) {
final subpart = subparts[i];
if (subpart is String) {
pathBuffer.write('(?:${escapeRegex(subpart)})');
pathBuffer.write('(?:${RegExp.escape(subpart)})');
} else if ((subpart as Match).group(1) == '?') {
_compileQuery(prevParts: subparts.sublist(i + 1));
break;
Expand Down Expand Up @@ -482,7 +480,7 @@ class _Compiler {
for (var i = 0; i < prevParts.length; i++) {
final subpart = prevParts[i];
if (subpart is String) {
fragmentBuffer.write('(?:${escapeRegex(subpart)})');
fragmentBuffer.write('(?:${RegExp.escape(subpart)})');
} else if ((subpart as Match).group(1) == '?') {
throw ParseException('?');
} else if (subpart.group(1) == '#') {
Expand All @@ -493,7 +491,7 @@ class _Compiler {
while (_parts.moveNext()) {
final part = _parts.current;
if (part is String) {
fragmentBuffer.write('(?:${escapeRegex(part)})');
fragmentBuffer.write('(?:${RegExp.escape(part)})');
} else {
final match = part as Match;
final op = match.group(2);
Expand Down
6 changes: 1 addition & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
name: uri
version: 1.1.0-wip
version: 2.0.0-wip
description: >-
Utilities for building and parsing URIs, including support for parsing
URI templates as defined in RFC 6570.
repository: https://github.com/google/uri.dart
environment:
sdk: ^3.1.0

dependencies:
matcher: ^0.12.10
quiver: ^3.0.0

dev_dependencies:
dart_flutter_team_lints: ^3.0.0
test: ^1.16.6