Skip to content

Commit

Permalink
0.8.3 stars crash fixed + log bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jolav committed Feb 14, 2023
1 parent a8d92b1 commit 7679ecd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

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

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

**version 0.8.2**
**version 0.8.3**

1. [Count LOC (lines of code) online from github/gitlab repos or zipped uploaded folder](#count-loc-online)
2. [CORS proxy](#cors-proxy)
Expand Down
23 changes: 16 additions & 7 deletions _utils/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package _utils

import (
"fmt"
"log"
"net/http"
"os"
Expand All @@ -11,21 +12,29 @@ import (
)

// AddHit ...
func AddHit(w http.ResponseWriter, r *http.Request,
service, mode string, hLog *log.Logger) {
func AddHit(w http.ResponseWriter, r *http.Request, service, mode string,
hLog *log.Logger) {
ip := GetIP(r)
sv := strings.ToUpper(service)
host := r.Header.Get("Origin")
host := r.Header.Get("Host")
if host == "" {
host = " ? "
host = r.Header.Get("Origin")
if host == "" {
host = r.Header.Get("Referer")
if host == "" {
host = "???"
}
}
}
quest := r.Form.Get("quest")

askingFor := strings.Trim(fmt.Sprint(r.URL), string(r.URL.Path))

if mode == "production" {
hLog.Println(ip, sv, host, quest)
hLog.Println(ip, sv, host, askingFor)
hitUrl := "http://localhost:3970/addHit/" + service
saveHit(w, hitUrl)
} else {
log.Println(ip, sv, host, quest)
log.Println(ip, sv, host, askingFor)
}
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/jolav/codetabs/weather"
)

var version = "0.8.2"
var version = "0.8.3"
var when = "undefined"

type Conf struct {
Expand Down
4 changes: 4 additions & 0 deletions stars/stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func Router(w http.ResponseWriter, r *http.Request) {
s.cleanStarsStruct()
r.ParseForm()
data := r.Form.Get("repo")
if data == "" {
u.BadRequest(w, r)
return
}
s.source = data[0:2]
s.repo = data[2:len(data)]
aux := strings.Split(s.repo, "/")
Expand Down
2 changes: 1 addition & 1 deletion www/_public/templates/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="centerText">
API doc
<small>
<small>(version 0.8.2)</small>
<small>(version 0.8.3)</small>
</small>
</h2>
<!-- End -->

0 comments on commit 7679ecd

Please sign in to comment.