mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-10-31 09:15:07 +03:00 
			
		
		
		
	Fix open URI RIVM-19
This commit is contained in:
		
							parent
							
								
									3aaf253ce4
								
							
						
					
					
						commit
						ea0125ee1e
					
				
					 1 changed files with 22 additions and 11 deletions
				
			
		|  | @ -96,15 +96,26 @@ func main() { | ||||||
| 	if confui.IndexHtml == "" { | 	if confui.IndexHtml == "" { | ||||||
| 		confui.IndexHtml = "index.html" | 		confui.IndexHtml = "index.html" | ||||||
| 	} | 	} | ||||||
| 	confui.IndexHtml, err = filepath.Abs(confui.IndexHtml) | 	//Check is it URL already | ||||||
| 	if err != nil { | 	indexUrl, err := url.ParseRequestURI(confui.IndexHtml) | ||||||
| 		panic(errors.New("Index file not found: " + err.Error())) | 	if err != nil || len(indexUrl.Scheme) < 2 { // handling no scheme at all and windows c:\ as scheme detection | ||||||
| 	} | 		confui.IndexHtml, err = filepath.Abs(confui.IndexHtml) | ||||||
| 
 | 		if err != nil { | ||||||
| 	if stat, err := os.Stat(confui.IndexHtml); err != nil { | 			panic(errors.New("Index file not found: " + err.Error())) | ||||||
| 		panic(errors.New("Index file not found or permissians denied: " + err.Error())) | 		} | ||||||
| 	} else if stat.IsDir() { | 		if stat, err := os.Stat(confui.IndexHtml); err != nil { | ||||||
| 		panic(errors.New(fmt.Sprintf("Index file %v not found", confui.IndexHtml))) | 			panic(errors.New("Index file not found or permissians denied: " + err.Error())) | ||||||
|  | 		} else if stat.IsDir() { | ||||||
|  | 			panic(errors.New(fmt.Sprintf("Index file %v not found", confui.IndexHtml))) | ||||||
|  | 		} | ||||||
|  | 		path_prefix := "" | ||||||
|  | 		if len(indexUrl.Scheme) == 1 { | ||||||
|  | 			path_prefix = "/" | ||||||
|  | 		} | ||||||
|  | 		indexUrl, err = url.ParseRequestURI("file://" + path_prefix + strings.ReplaceAll(confui.IndexHtml, "\\", "/")) | ||||||
|  | 		if err != nil { | ||||||
|  | 			panic(errors.New("Index file URL parse error: " + err.Error())) | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	w.Bind("onLoad", func() { | 	w.Bind("onLoad", func() { | ||||||
|  | @ -133,8 +144,8 @@ func main() { | ||||||
| 	w.Bind("ping", func(peer_list string) { | 	w.Bind("ping", func(peer_list string) { | ||||||
| 		go ping(w, peer_list) | 		go ping(w, peer_list) | ||||||
| 	}) | 	}) | ||||||
| 	log.Printf("Opening: %v", confui.IndexHtml) | 	log.Printf("Opening: %v", indexUrl) | ||||||
| 	w.Navigate(confui.IndexHtml) | 	w.Navigate(indexUrl.String()) | ||||||
| 	w.Run() | 	w.Run() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mihail Slobodyanuk
						Mihail Slobodyanuk