Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 7fc7526

Browse files
committed
Uses fetch API
1 parent 9029177 commit 7fc7526

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

model/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.6.0
2+
3+
* Uses `fetch` based JS API to handle HTTP request in Flutter Web instead of default implementation from `http` packages.
4+
15
## 3.5.2
26

37
* `TwitterCardPropertyParser.legacyDomain`'s default value becomes `false` and marked as deprecated.

model/lib/src/client/client.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import '../disguise_ua/disguise_ua.dart';
99
import '../exception/content_type_mismatched.dart';
1010
import '../fetch/fetch.dart' show MetaFetch;
1111

12+
import 'client_provider_normal.dart'
13+
if (dart.library.js_interop) 'client_provider_web.dart';
14+
1215
part 'mock_client.dart';
1316

1417
/// [Client] implementation for OgHref packages.
@@ -23,7 +26,7 @@ final class OgHrefClient extends BaseClient {
2326
/// Allow redirection if necessary.
2427
final bool redirect;
2528

26-
final Client _c = Client();
29+
final Client _c = initializeClient();
2730

2831
/// Current user agent preference of following requests.
2932
static String _userAgent = DEFAULT_USER_AGENT_STRING;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:http/http.dart' show Client;
2+
import 'package:meta/meta.dart';
3+
4+
@internal
5+
Client initializeClient() => Client();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'package:fetch_client/fetch_client.dart';
2+
import 'package:http/http.dart' show Client;
3+
import 'package:meta/meta.dart';
4+
5+
@internal
6+
Client initializeClient() => FetchClient(mode: RequestMode.cors);

model/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: oghref_model
22
description: Object standarized definition with parser interface for constructing rich information of given URL among various metadata protocols.
3-
version: 3.5.2
3+
version: 3.6.0
44
repository: https://github.com/rk0cc/oghref/tree/main/model
55
issue_tracker: https://github.com/rk0cc/oghref/issues
66
funding:
@@ -18,6 +18,7 @@ dependencies:
1818
mime_dart: ^3.0.0
1919
path: ^1.8.3
2020
web: ^0.5.1
21+
fetch_client: ^1.1.2
2122
dev_dependencies:
2223
lints: ^4.0.0
2324
test: ^1.24.8

0 commit comments

Comments
 (0)