remove leading slashes from URI paths

This commit is contained in:
Eli Geller 2023-08-14 18:21:09 -04:00
parent 3e50d70460
commit 4e28e5f5b9
No known key found for this signature in database
GPG Key ID: 883F38F3E9050143
5 changed files with 17 additions and 17 deletions

View File

@ -86,8 +86,8 @@ class Database extends _$Database {
Future<WasmDatabaseResult> connect() async { Future<WasmDatabaseResult> connect() async {
final result = await WasmDatabase.open( final result = await WasmDatabase.open(
databaseName: 'todo_example', databaseName: 'todo_example',
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.dart.js'), driftWorkerUri: Uri.parse('drift_worker.dart.js'),
); );
if (!result.chosenImplementation.fullySupported) { if (!result.chosenImplementation.fullySupported) {

View File

@ -10,8 +10,8 @@ DatabaseConnection connectOnWeb() {
return DatabaseConnection.delayed(Future(() async { return DatabaseConnection.delayed(Future(() async {
final result = await WasmDatabase.open( final result = await WasmDatabase.open(
databaseName: 'my_app_db', // prefer to only use valid identifiers here databaseName: 'my_app_db', // prefer to only use valid identifiers here
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.dart.js'), driftWorkerUri: Uri.parse('drift_worker.dart.js'),
); );
if (result.missingFeatures.isNotEmpty) { if (result.missingFeatures.isNotEmpty) {
@ -64,8 +64,8 @@ DatabaseConnection migrateAndConnect() {
// Then you can migrate like this // Then you can migrate like this
final result = await WasmDatabase.open( final result = await WasmDatabase.open(
databaseName: 'my_app', databaseName: 'my_app',
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.dart.js'), driftWorkerUri: Uri.parse('drift_worker.dart.js'),
initializeDatabase: () async { initializeDatabase: () async {
// Manually open the file system previously used // Manually open the file system previously used
final fs = await IndexedDbFileSystem.open(dbName: 'my_app'); final fs = await IndexedDbFileSystem.open(dbName: 'my_app');
@ -101,8 +101,8 @@ DatabaseConnection migrateFromLegacy() {
// #docregion migrate-legacy // #docregion migrate-legacy
final result = await WasmDatabase.open( final result = await WasmDatabase.open(
databaseName: 'my_app', databaseName: 'my_app',
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.dart.js'), driftWorkerUri: Uri.parse('drift_worker.dart.js'),
initializeDatabase: () async { initializeDatabase: () async {
final storage = await DriftWebStorage.indexedDbIfSupported('old_db'); final storage = await DriftWebStorage.indexedDbIfSupported('old_db');
await storage.open(); await storage.open();

View File

@ -18,8 +18,8 @@ void main() async {
try { try {
final db = await WasmDatabase.open( final db = await WasmDatabase.open(
databaseName: 'test_db', databaseName: 'test_db',
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.dart.js'), driftWorkerUri: Uri.parse('drift_worker.dart.js'),
); );
results.innerText += ''' results.innerText += '''

View File

@ -9,8 +9,8 @@ DatabaseConnection connect() {
return DatabaseConnection.delayed(Future(() async { return DatabaseConnection.delayed(Future(() async {
final db = await WasmDatabase.open( final db = await WasmDatabase.open(
databaseName: 'todo-app', databaseName: 'todo-app',
sqlite3Uri: Uri.parse('/sqlite3.wasm'), sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('/drift_worker.js'), driftWorkerUri: Uri.parse('drift_worker.js'),
); );
if (db.missingFeatures.isNotEmpty) { if (db.missingFeatures.isNotEmpty) {

View File

@ -11,8 +11,8 @@ import 'package:web_wasm/src/database.dart';
import 'package:sqlite3/wasm.dart'; import 'package:sqlite3/wasm.dart';
const dbName = 'drift_test'; const dbName = 'drift_test';
final sqlite3WasmUri = Uri.parse('/sqlite3.wasm'); final sqlite3WasmUri = Uri.parse('sqlite3.wasm');
final driftWorkerUri = Uri.parse('/worker.dart.js'); final driftWorkerUri = Uri.parse('worker.dart.js');
TestDatabase? openedDatabase; TestDatabase? openedDatabase;
StreamQueue<void>? tableUpdates; StreamQueue<void>? tableUpdates;
@ -82,18 +82,18 @@ Future<Uint8List?> _initializeDatabase() async {
// Let's first open a custom WasmDatabase, the way it would have been // Let's first open a custom WasmDatabase, the way it would have been
// done before WasmDatabase.open. // done before WasmDatabase.open.
final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('/sqlite3.wasm')); final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('sqlite3.wasm'));
final fs = await IndexedDbFileSystem.open(dbName: dbName); final fs = await IndexedDbFileSystem.open(dbName: dbName);
sqlite3.registerVirtualFileSystem(fs, makeDefault: true); sqlite3.registerVirtualFileSystem(fs, makeDefault: true);
final wasmDb = WasmDatabase(sqlite3: sqlite3, path: '/app.db'); final wasmDb = WasmDatabase(sqlite3: sqlite3, path: 'app.db');
final db = TestDatabase(wasmDb); final db = TestDatabase(wasmDb);
await db await db
.into(db.testTable) .into(db.testTable)
.insert(TestTableCompanion.insert(content: 'from old database')); .insert(TestTableCompanion.insert(content: 'from old database'));
await db.close(); await db.close();
final (file: file, outFlags: _) = fs.xOpen(Sqlite3Filename('/app.db'), 0); final (file: file, outFlags: _) = fs.xOpen(Sqlite3Filename('app.db'), 0);
final blob = Uint8List(file.xFileSize()); final blob = Uint8List(file.xFileSize());
file.xRead(blob, 0); file.xRead(blob, 0);
file.xClose(); file.xClose();