File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ exposed by this class execute synchronously.
88
88
added: v22.5.0
89
89
-->
90
90
91
- * ` location ` {string} The location of the database. A SQLite database can be
91
+ * ` location ` {string} | {Buffer} | {URL} The location of the database. A SQLite database can be
92
92
stored in a file or completely [ in memory] [ ] . To use a file-backed database,
93
93
the location should be a file path. To use an in-memory database, the location
94
94
should be the special name ` ':memory:' ` .
@@ -533,8 +533,8 @@ added: REPLACEME
533
533
-->
534
534
535
535
* ` sourceDb ` {DatabaseSync} The database to backup. The source database must be open.
536
- * ` destination ` {string} The path where the backup will be created. If the file already exists, the contents will be
537
- overwritten.
536
+ * ` destination ` {string} | {Buffer} | {URL} The path where the backup will be created. If the file already exists,
537
+ the contents will be overwritten.
538
538
* ` options ` {Object} Optional configuration for the backup. The
539
539
following properties are supported:
540
540
* ` source ` {string} Name of the source database. This can be ` 'main' ` (the default primary database) or any other
Original file line number Diff line number Diff line change 1
1
#include " node_sqlite.h"
2
2
#include < path.h>
3
+ #include " ada.h"
3
4
#include " base_object-inl.h"
4
5
#include " debug_utils-inl.h"
5
6
#include " env-inl.h"
@@ -593,19 +594,24 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
593
594
return ;
594
595
}
595
596
596
- if (!args[0 ]->IsString ()) {
597
+ Local<Value> path = args[0 ];
598
+ if (!path->IsString () && !path->IsUint8Array ()) {
597
599
THROW_ERR_INVALID_ARG_TYPE (env->isolate (),
598
- " The \" path\" argument must be a string." );
600
+ " The \" path\" argument must be a string, "
601
+ " Uint8Array, or URL without null bytes." );
599
602
return ;
600
603
}
601
604
602
605
std::string location =
603
606
Utf8Value (env->isolate (), args[0 ].As <String>()).ToString ();
604
- DatabaseOpenConfiguration open_config (std::move (location));
607
+ auto parsed_url = ada::parse<ada::url_aggregator>(location, nullptr );
608
+ if (parsed_url && parsed_url->type != ada::scheme::FILE) {
609
+ THROW_ERR_INVALID_URL_SCHEME (env->isolate ());
610
+ }
605
611
612
+ DatabaseOpenConfiguration open_config (std::move (location));
606
613
bool open = true ;
607
614
bool allow_load_extension = false ;
608
-
609
615
if (args.Length () > 1 ) {
610
616
if (!args[1 ]->IsObject ()) {
611
617
THROW_ERR_INVALID_ARG_TYPE (env->isolate (),
You can’t perform that action at this time.
0 commit comments