Browse Source

fix: handle single word bundle identifier when resolving Android domain (#6313)

Lucas Fernandes Nogueira 2 years ago
parent
commit
60a8b07dc7

+ 7 - 0
.changes/fix-empty-identifier.md

@@ -0,0 +1,7 @@
+---
+"cli.rs": patch
+"cli.js": patch
+"tauri-macros": patch
+---
+
+Resolve Android package name from single word bundle identifiers.

+ 1 - 1
core/tauri-build/src/lib.rs

@@ -274,7 +274,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
   let last = s.clone().count() - 1;
   let mut android_package_prefix = String::new();
   for (i, w) in s.enumerate() {
-    if i != last {
+    if i == 0 || i != last {
       android_package_prefix.push_str(w);
       android_package_prefix.push('_');
     }

File diff suppressed because it is too large
+ 0 - 0
examples/api/dist/assets/index.js


+ 10 - 11
tooling/cli/src/mobile/mod.rs

@@ -27,7 +27,7 @@ use std::{
   fs::{create_dir_all, read_to_string, write},
   net::SocketAddr,
   path::PathBuf,
-  process::ExitStatus,
+  process::{exit, ExitStatus},
   sync::{
     atomic::{AtomicBool, Ordering},
     Arc,
@@ -256,18 +256,17 @@ fn get_app(config: &TauriConfig) -> App {
     domain.push_str(w);
     domain.push('.');
   }
-  domain.pop();
-
-  let s = config.tauri.bundle.identifier.split('.');
-  let last = s.clone().count() - 1;
-  let mut reverse_domain = String::new();
-  for (i, w) in s.enumerate() {
-    if i != last {
-      reverse_domain.push_str(w);
-      reverse_domain.push('.');
+  if domain.is_empty() {
+    domain = config.tauri.bundle.identifier.clone();
+    if domain.is_empty() {
+      log::error!(
+        "Bundle identifier set in `tauri.conf.json > tauri > bundle > identifier` cannot be empty"
+      );
+      exit(1);
     }
+  } else {
+    domain.pop();
   }
-  reverse_domain.pop();
 
   let interface = AppInterface::new(
     config,

Some files were not shown because too many files changed in this diff