lijian 48c2e0e9f9 依赖更新为 go mod il y a 1 an
..
.gitignore 48c2e0e9f9 依赖更新为 go mod il y a 1 an
LICENSE cf619cc6db 更新api il y a 6 ans
README.md 48c2e0e9f9 依赖更新为 go mod il y a 1 an
default_rules.go 48c2e0e9f9 依赖更新为 go mod il y a 1 an
dev.yml 48c2e0e9f9 依赖更新为 go mod il y a 1 an
referrer.go cf619cc6db 更新api il y a 6 ans
rich_url.go cf619cc6db 更新api il y a 6 ans
rules.go cf619cc6db 更新api il y a 6 ans

README.md

goreferrer

A Go module that analyzes and classifies different kinds of referrer URLs (search, social, ...).

Example

package main

import (
	"fmt"

	"github.com/Shopify/goreferrer"
)

var urls = []string{
	"http://ca.search.yahoo.com/search?p=hello",
	"https://twitter.com/jdoe/status/391149968360103936",
	"http://yoursite.com/links",
}

func main() {
	for _, url := range urls {
		r := goreferrer.DefaultRules.Parse(url)
		switch r.Type {
		case goreferrer.Search:
			fmt.Printf("Search %s: %s\n", r.Label, r.Query)
		case goreferrer.Social:
			fmt.Printf("Social %s\n", r.Label)
		case goreferrer.Indirect:
			fmt.Printf("Indirect: %s\n", r.URL)
		}
	}
}

Result:

Search Yahoo: hello
Social Twitter
Indirect: http://yoursite.com/links