Pass unresolved onebox links to onebox

I’m not sure it’s a bug - To me it seems like it is.

Let me explain quickly. On my site people can create private recipes. They can then create a special URL to share this private recipe with people. A “token” is added to the query string: http://tjek.nu/r/7x55?token=6d62d94499ac10e (this is a shortened URL) - The onebox’er correctly parses the data and shows a onebox. However, the onebox now links directly to the content: http://e-liquid-recipes.com/recipe/940255 - which won’t work for people beacuse of the missing “token” that was in the original URL (the original sets a session variable and redirects).

My question is this: Shouldn’t the onebox use the original URL that you wanted to share?

I’ve worked around it by adding the token to the redirect and added code to support this in the app…

3 Likes

Interesting edge case here with final destination @eviltrout

3 Likes

This one is tricky due to the way the app calculates the final destination for a URL for security reasons. If a URL has several redirects we resolve the final URL and then pass that to onebox for rendering.

I suppose we could pass the original URL through and have the onebox render that if present, but I suspect in most cases you’d prefer to have it link to the redirected content, not the initial content?

4 Likes

The latter seems better to me, but do you guys have a policy about shortlinks in general? Do you expand them for the benefit of the users? I know that the shortlink-services offer statistics, but they wouldn’t work on Discourse… Other than that, the only edge case I can think of is sort of like mine, where the shortlink holds a key to accessing the final URL…

Oh wow cool so a shortened URL will be resolved for onebox? Let’s see

I pasted https://goo.gl/EwfRSe

I pasted https://goo.gl/1Hq0XP

Very cool @eviltrout – long term this is way more healthy since the final link will be stored in the post, not (x) intermediary dumb redirect service URLs, that might disappear or go out of business…

5 Likes

Sort of a rebake will still break stuff if intermediates die

2 Likes

That’s always true of URL shorteners, though, isn’t it?

2 Likes

Well, it would be conceivable that discourse disposes of the short url and declares independency from the short code provider (who will not be amused).

For obvious reasons, I’d prefer the initial URL to be passed to the onebox… :slight_smile: