Skip to content

Recognize 'blob:' URLs as absolute#28

Open
zlamma wants to merge 2 commits into
ractivejs:masterfrom
zlamma:support_blob_urls
Open

Recognize 'blob:' URLs as absolute#28
zlamma wants to merge 2 commits into
ractivejs:masterfrom
zlamma:support_blob_urls

Conversation

@zlamma

@zlamma zlamma commented Jun 19, 2016

Copy link
Copy Markdown

With blob URLs you can play with single-page-components purely in the browser.
E.g. you can feed Ractive.load a URL constructed from a string like this:

var template = '<script>component.exports ={ data:{ Name: "Alice" }}</script>'+
              '<h3>Hello {{Name}}!</h3>';
var url = URL.createObjectURL(new Blob([template], { type: 'text/html' }))
Ractive.load( url )
    .then(ShowItSomewhere)

Or, better yet, from a text input box on a component editor page.

@zlamma zlamma changed the title Make the 'absolute URL detection' code correctly recognize 'blob:' URLs as absolute Recognize 'blob:' URLs as absolute Jun 19, 2016
@ghost

ghost commented Jun 20, 2016

Copy link
Copy Markdown

Probably requires tests 😄

@zlamma

zlamma commented Jun 20, 2016

Copy link
Copy Markdown
Author

Would love to but it's the harder part for me. Currently fighting with getting the thing to build and pass tests on Windoze, as this is what I'm currently stuck with 😩. Plently of tests failing because of line endings :(

UPDATE: OK. I think I nailed the Windows problem and I think it can be fixed in the repo for everyone using Windows. Please see pull request #29 . If you merge it, it will make it easier for me to update this PR with a test :)

@zlamma zlamma force-pushed the support_blob_urls branch from ca81aea to e094943 Compare June 20, 2016 23:37
@zlamma zlamma force-pushed the support_blob_urls branch 2 times, most recently from ac87a13 to e2b5028 Compare June 20, 2016 23:43
@zlamma

zlamma commented Jun 20, 2016

Copy link
Copy Markdown
Author

Added the test now & forced.

@zlamma

zlamma commented Jun 22, 2016

Copy link
Copy Markdown
Author

Alternatively, not to bake in too much complexity into this dumb logic, rcu can be made to work with URL objects (browsers, node), which are always absolute.
But how would we detect them cross-platform way? Perhaps checking existence of a property that exists in both node and browsers, like href?

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.

1 participant