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

Add support for base element #358

Merged
merged 2 commits into from
Sep 28, 2016
Merged

Add support for base element #358

merged 2 commits into from
Sep 28, 2016

Conversation

gjtorikian
Copy link
Owner

From MDN

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document.

Successor to #265, closes #166.

/cc @bkeepers

@gjtorikian gjtorikian merged commit 5065dce into master Sep 28, 2016
@gjtorikian gjtorikian deleted the ace-of-base branch September 28, 2016 20:36
@lurch
Copy link

lurch commented Sep 28, 2016

Bonus points for the branch-name :-)

@lurch
Copy link

lurch commented Sep 28, 2016

I don't know if it's ever used in practice, but according to the example in https://html.spec.whatwg.org/multipage/semantics.html#the-base-element

In this example, a base element is used to set the document base URL:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>This is an example for the &lt;base&gt; element</title>
        <base href="http://www.example.com/news/index.html">
    </head>
    <body>
        <p>Visit the <a href="archives.html">archives</a>.</p>
    </body>
</html>
The link in the above example would be a link to "http://www.example.com/news/archives.html".

you can actually set base href to a page-name, and it looks like the 'effective' base href then becomes the directory that file is in.
Is it worth adding a unit-test for that?

@bkeepers
Copy link
Contributor

It's probably worth adding a test for it, but Addressable::URI.join, which is used in the implementation, does handle this scenario:

>  Addressable::URI.join("http://www.example.com/news/index.html", "archives.html").to_s
=> "http://www.example.com/news/archives.html"

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.

HTML base tag
3 participants