This project is archived and is in readonly mode.

#5774 ✓committed
Stephen Celis

Protocol-relative URLs

Reported by Stephen Celis | October 9th, 2010 @ 03:33 PM | in 3.1

ActionPack doesn't support the generation of protocol-relative URLs right now, e.g. "//google.com", which the browser will follow with "http" or "https", accordingly.

I've found protocol-relative URLs to be especially helpful when providing embed code for users, simplifying the logic to load JS off the right protocol.

This patch adds support and tests the following methods of attaining protocol-relative URLs:

    embed_code_path(@widget, :protocol => false)
    embed_code_path(@widget, :protocol => '//')

The patch also fixes the case where a protocol may be declared with ":" as the separator (e.g., "http:", as JavaScript provides).

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages