mirror of
https://github.com/wahyd4/golink.git
synced 2026-08-09 05:05:56 +10:00
cmd/golink: short names must begin with word char
also move special "system" URLs like /_/export and /_/base to /.export and /.base, respectively. Change-Id: Ica2b11ce3f97575c2755ae1516dd4bc6d814ece4
This commit is contained in:
@@ -88,8 +88,9 @@ func main() {
|
||||
go flushStatsLoop()
|
||||
|
||||
http.HandleFunc("/", serveGo)
|
||||
http.HandleFunc("/_/export", serveExport)
|
||||
http.Handle("/_/static/", http.StripPrefix("/_/", http.FileServer(http.FS(embeddedFS))))
|
||||
http.HandleFunc("/.export", serveExport)
|
||||
http.Handle("/_/export", http.RedirectHandler("/.export", http.StatusMovedPermanently))
|
||||
http.Handle("/.static/", http.StripPrefix("/.", http.FileServer(http.FS(embeddedFS))))
|
||||
|
||||
if *dev != "" {
|
||||
log.Printf("Running in dev mode on %s ...", *dev)
|
||||
@@ -338,7 +339,7 @@ func userExists(ctx context.Context, login string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var reShortName = regexp.MustCompile(`^[\w\-\.]+$`)
|
||||
var reShortName = regexp.MustCompile(`^\w[\w\-\.]*$`)
|
||||
|
||||
// serveSave handles requests to save or update a Link. Both short name and
|
||||
// long URL are validated for proper format. Existing links may only be updated
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>go/</title>
|
||||
<link rel="stylesheet" href="/_/static/base.css">
|
||||
<link rel="stylesheet" href="/.static/base.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body class="flex flex-col min-h-screen">
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
curl -o $(dirname "$0")/link-snapshot.json 'http://go/_/export?clicks=false'
|
||||
curl -o $(dirname "$0")/link-snapshot.json 'http://go/.export?clicks=false'
|
||||
|
||||
Reference in New Issue
Block a user