this repo has no description smallweb.run
smallweb
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove the wildcard behavior

pomdtr 740cb6f9 9e053fdf

+4 -25
+1 -2
api/api.go
··· 62 62 return 63 63 } 64 64 65 - subdomains := strings.Split(strings.TrimSuffix(domain, "."+k.String("domain")), ".") 66 - appname := subdomains[len(subdomains)-1] 65 + appname := strings.TrimSuffix(domain, "."+k.String("domain")) 67 66 appDir := filepath.Join(utils.ExpandTilde(k.String("dir")), appname) 68 67 if _, err := app.LoadApp(appDir, k.String("domain")); err != nil { 69 68 http.Error(w, err.Error(), http.StatusInternalServerError)
+3 -19
cmd/up.go
··· 73 73 74 74 target.Host = "www." + k.String("domain") 75 75 http.Redirect(w, r, target.String(), http.StatusTemporaryRedirect) 76 + return 76 77 } 77 78 78 79 w.WriteHeader(http.StatusNotFound) 79 80 return 80 81 } 81 82 82 - appname := func() string { 83 - if appname := strings.TrimSuffix(r.Host, fmt.Sprintf(".%s", k.String("domain"))); utils.FileExists(filepath.Join(rootDir, appname)) { 84 - return appname 85 - } 86 - 87 - parts := strings.Split(r.Host, ".") 88 - base := strings.Join(parts[1:], ".") 89 - if base == k.String("domain") { 90 - return "" 91 - } 92 - 93 - if appname := strings.TrimSuffix(base, fmt.Sprintf(".%s", k.String("domain"))); utils.FileExists(filepath.Join(rootDir, appname)) { 94 - return appname 95 - } 96 - 97 - return "" 98 - }() 99 - 100 - if appname == "" { 83 + if !strings.HasSuffix(r.Host, "."+k.String("domain")) { 101 84 w.WriteHeader(http.StatusNotFound) 102 85 return 103 86 } 104 87 88 + appname := strings.TrimSuffix(r.Host, "."+k.String("domain")) 105 89 a, err := app.LoadApp(filepath.Join(rootDir, appname), k.String("domain")) 106 90 if err != nil { 107 91 w.WriteHeader(http.StatusNotFound)
-4
docs/src/guides/routing.md
··· 18 18 - `api.example.com` → `~/smallweb/api` 19 19 - `blog.example.com` → `~/smallweb/blog` 20 20 21 - - Nested subdomains: 22 - - Any subdomain like `*.api.example.com` is handled by its parent directory 23 - - For example: `test.api.example.com` → `~/smallweb/api` 24 - 25 21 - Root domain behavior: 26 22 - Requests to `example.com` automatically redirect to `www.example.com` if the `www` directory exists 27 23 - If the `www` directory does not exist, a 404 error is returned