<commit_before>package gadata

import (
	"fmt"
	"log"
	"net/http"
	"os/exec"
	"strings"
)

// BrowserOpen opens a URL is the OS' default web browser
func BrowserOpen(url string) error {
	return exec.Command("open", url).Run()
}

// WebCallback listens on a predefined port for a oauth response
// sends back via channel once it receives a response and shuts down.
func WebCallback(ch chan string) {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if strings.Contains(r.RequestURI, "/?") {
			block := strings.SplitAfter(r.RequestURI, "/?")[1]
			if !strings.Contains(block, "code=") {
				ch <- block
			} else {
				ch <- strings.SplitAfter(block, "code=")[1]
				fmt.Fprintln(w, "Authentication completed, you can close this window.")
				close(ch)
				return
			}
		}
		fmt.Fprintln(w, "Error encountered during authentication.")
		return
	})

	log.Fatalf("Server exited: %v", http.ListenAndServe(ReturnURI, nil))
}<commit_msg>codeship doesn't like default browser :(<commit_after>package gadata

import (
	"fmt"
	"log"
	"net/http"
	"os/exec"
	"strings"
)

// BrowserOpen opens a URL is the OS' default web browser
// func BrowserOpen(url string) error {
// 	return exec.Command("open", url).Run()
// }

// WebCallback listens on a predefined port for a oauth response
// sends back via channel once it receives a response and shuts down.
func WebCallback(ch chan string) {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if strings.Contains(r.RequestURI, "/?") {
			block := strings.SplitAfter(r.RequestURI, "/?")[1]
			if !strings.Contains(block, "code=") {
				ch <- block
			} else {
				ch <- strings.SplitAfter(block, "code=")[1]
				fmt.Fprintln(w, "Authentication completed, you can close this window.")
				close(ch)
				return
			}
		}
		fmt.Fprintln(w, "Error encountered during authentication.")
		return
	})

	log.Fatalf("Server exited: %v", http.ListenAndServe(ReturnURI, nil))
}
{'fraction_non_alphanumeric': 0.14366632337796087, 'fraction_numerical': 0.0020597322348094747, 'mean_word_length': 3.797530864197531, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1915528', 'n_tokens_mistral': 702, 'n_tokens_neox': 630, 'n_words': 187}