Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow path after a shortcut: go/short/foobar #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Allow path after a shortcut: go/short/foobar #18

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 14, 2018

This allows adding additional path to a shortened URL. For example, if
go/short redirects to http://example.com, go/short/foobar will redirect
to http://example.com/foobar.

An example usage is to shorten Google Docs headings. go/mydoc can
redirect to a document. go/mydoc/#heading=h.asdfgh123456 can then
redirect to a specific heading in the doc.

This feature is supported in the original golinks at Google.

Next step: Create a chrome extension that links to the go/ server and
shortens a given link based on the shortcuts already registered

This allows adding additional path to a shortened URL. For example, if
go/short redirects to http://example.com, go/short/foobar will redirect
to http://example.com/foobar.

An example usage is to shorten Google Docs headings. go/mydoc can
redirect to a document. go/mydoc/#heading=h.asdfgh123456 can then
redirect to a specific heading in the doc.

This feature is supported in the original golinks at Google.

Next step: Create a chrome extension that links to the go/ server and
shortens a given link based on the shortcuts already registered
@mathieujobin
Copy link

shouldn't we have a special placeholder defined in the route, instead of simply appending ?

I get that appending cover most cases but I wonder...

@mathieujobin
Copy link

there is a compilation error in api.go, need to update the 3 calls to parseName

 GOPATH=`pwd` go get github.com/deepanshu-zendrive/go
# github.com/kellegous/go/web
src/github.com/kellegous/go/web/api.go:78:4: assignment mismatch: 1 variable but parseName returns 2 values
src/github.com/kellegous/go/web/api.go:128:4: assignment mismatch: 1 variable but parseName returns 2 values
src/github.com/kellegous/go/web/api.go:148:4: assignment mismatch: 1 variable but parseName returns 2 values

@@ -58,7 +58,7 @@ func getDefault(ctx *context.Context, w http.ResponseWriter, r *http.Request) {
}

http.Redirect(w, r,
rt.URL,
rt.URL+s,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like s contains the leading slash... i don't think it should.
you might want to add after an param= at the end, but now I am getting param=/foobar which is not what I want.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added +1 to parseName function

mathieujobin@e47e38e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants