Skip to content

Commit 7679ecd

Browse files
committed
0.8.3 stars crash fixed + log bug
1 parent a8d92b1 commit 7679ecd

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
![Version](https://img.shields.io/badge/version-0.8.2-orange.svg)
2+
![Version](https://img.shields.io/badge/version-0.8.3-orange.svg)
33
![Maintained YES](https://img.shields.io/badge/Maintained%3F-yes-green.svg)
44
![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)
55

66
# ![logo](https://github.com/jolav/codetabs/blob/master/www/_public/icons/ct/ct64r.png?raw=true) **ONLINE TOOLS ([codetabs.com](https://codetabs.com))**
77

8-
**version 0.8.2**
8+
**version 0.8.3**
99

1010
1. [Count LOC (lines of code) online from github/gitlab repos or zipped uploaded folder](#count-loc-online)
1111
2. [CORS proxy](#cors-proxy)

_utils/stats.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package _utils
44

55
import (
6+
"fmt"
67
"log"
78
"net/http"
89
"os"
@@ -11,21 +12,29 @@ import (
1112
)
1213

1314
// AddHit ...
14-
func AddHit(w http.ResponseWriter, r *http.Request,
15-
service, mode string, hLog *log.Logger) {
15+
func AddHit(w http.ResponseWriter, r *http.Request, service, mode string,
16+
hLog *log.Logger) {
1617
ip := GetIP(r)
1718
sv := strings.ToUpper(service)
18-
host := r.Header.Get("Origin")
19+
host := r.Header.Get("Host")
1920
if host == "" {
20-
host = " ? "
21+
host = r.Header.Get("Origin")
22+
if host == "" {
23+
host = r.Header.Get("Referer")
24+
if host == "" {
25+
host = "???"
26+
}
27+
}
2128
}
22-
quest := r.Form.Get("quest")
29+
30+
askingFor := strings.Trim(fmt.Sprint(r.URL), string(r.URL.Path))
31+
2332
if mode == "production" {
24-
hLog.Println(ip, sv, host, quest)
33+
hLog.Println(ip, sv, host, askingFor)
2534
hitUrl := "http://localhost:3970/addHit/" + service
2635
saveHit(w, hitUrl)
2736
} else {
28-
log.Println(ip, sv, host, quest)
37+
log.Println(ip, sv, host, askingFor)
2938
}
3039
}
3140

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/jolav/codetabs/weather"
2727
)
2828

29-
var version = "0.8.2"
29+
var version = "0.8.3"
3030
var when = "undefined"
3131

3232
type Conf struct {

stars/stars.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func Router(w http.ResponseWriter, r *http.Request) {
6262
s.cleanStarsStruct()
6363
r.ParseForm()
6464
data := r.Form.Get("repo")
65+
if data == "" {
66+
u.BadRequest(w, r)
67+
return
68+
}
6569
s.source = data[0:2]
6670
s.repo = data[2:len(data)]
6771
aux := strings.Split(s.repo, "/")

www/_public/templates/version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h2 class="centerText">
33
API doc
44
<small>
5-
<small>(version 0.8.2)</small>
5+
<small>(version 0.8.3)</small>
66
</small>
77
</h2>
88
<!-- End -->

0 commit comments

Comments
 (0)