ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

URL shortening doesn't work when passing the URL only flag: /?u=1 #186

Closed arkag closed 7 years ago

arkag commented 7 years ago
screen shot 2017-03-21 at 3 25 29 pm
# ishmael @ aegislash in ~ [15:22:58]
$ curl -F c=@- https://ptpb.pw/\?u\=1 <<< https://imgur.com/gallery/dT95uNi
https://ptpb.pw/wjs_

# ishmael @ aegislash in ~ [15:24:53]
$ curl -F c=@- https://ptpb.pw/u <<< https://imgur.com/gallery/dT95uNi
date: 2017-03-21T19:24:58.330693+00:00
digest: c0a697c0eee44a809469b0af5b46b5d3c98d3c6f
long: AMCml8Du5EqAlGmwr1tGtdPJjTxv
redirect: 1
short: jTxv
size: 33
status: created
url: https://ptpb.pw/jTxv

Different flag provides two different pastes, one gives me the actual redirect, the other gives me the url in a paste.

arkag commented 7 years ago

Also seems like the detection for strictly shortening the URL isn't working. I can't shorten this url either, it just pastes the url: https://ptpb.pw/wW4O

buhman commented 7 years ago

I'm very aware shorturl-related things could probably be improved.

I can't shorten this url either

The current behavior is: if it already exists as a paste, you can't (re)create it as a shorturl--this is because a paste with digest 12e63c3be3035fcfb4ce043134f2c5cca8c16e0e already exists, so instead of modifying it with the redirect=1 attribute like you probably expect, it returns the existing paste with no mutation. See the status: created vs status: already exists.

I could probably be easily convinced to tweak this in some way. Mildly related is #152.

/?u=1

I added this because people were complaining about how the default paste response behavior was "too complicated" or "too verbose", etc… This is only a display/response-related thing, and has zero impact on what is actually done during request processing--instead of yaml, you get just a single string which is the paste/shorturl. People use this in their shell aliases/functions for "easier" parsing I guess.

It is also completely unrelated to the /u route, despite being the same letter.

URL shortening doesn't work when passing the URL only flag: /?u=1

That's because that's not the shorturl route. You want /u instead.


Other than the API being bad/inconsistent (blame @silverp1), is there an actual bug here? Or do you have a suggested modification?

buhman commented 7 years ago

I also realize maybe you're actually asking for /u to support ?u=1 (/u?u=1), which I imagine it probably doesn't(?). I would definitely agree with a request to refactor that view completely, if that's the case.

arkag commented 7 years ago

So I think maybe I was being an idiot. I attempted to shorten this url just now and it seems to work: https://ptpb.pw/YhtO

I am using Hammerspoon on my Mac to create a pbpst like functionality on OSX. I've stopped trying to use the URL only output and instead am using regex to pull the url: via the tag in front of it.

It seems to be working, so I'll close this.

Sorry for the confusion!

buhman commented 7 years ago

No problem!