Skip to content

Commit

Permalink
Update rendered root to include custom subdomain
Browse files Browse the repository at this point in the history
This doesn't account for all generated url's only those in the initial
html and those generated by the client. However this seems to cover
most bases without having to completely refactor the url helper to have
access to the request object.
  • Loading branch information
aron committed Sep 9, 2012
1 parent ad4a496 commit 0f146f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/handlers/bin.js
Expand Up @@ -442,14 +442,22 @@ module.exports = Observable.extend({
helpers = this.helpers, helpers = this.helpers,
version = helpers.production ? helpers.set('version') : 'debug', version = helpers.production ? helpers.set('version') : 'debug',
created = req.flash('checksum') || {}, created = req.flash('checksum') || {},
root = helpers.url('', true),
_this = this, _this = this,
jsbin; jsbin;


// Insert the subdomain if the request has one. Ideally this should be
// done by the helper.url() function but it's not currently aware of the
// request object.
if (req.subdomain) {
root = root.replace('://', '://' + req.subdomain + '.');
}

jsbin = this.jsbin(bin, { jsbin = this.jsbin(bin, {
version: version, version: version,
token: req.session._csrf, token: req.session._csrf,
root: helpers.set('url full'), root: root,
static: helpers.set('static url'), static: helpers.urlForStatic(),
settings: config && config.settings, settings: config && config.settings,
// If we've pulled a just created bin out of the flash messages object // If we've pulled a just created bin out of the flash messages object
// then we check to see if the previously created bin is the one we're // then we check to see if the previously created bin is the one we're
Expand Down Expand Up @@ -486,8 +494,8 @@ module.exports = Observable.extend({
custom_css: config && config.css, custom_css: config && config.css,
scripts: helpers.production ? false : scripts, scripts: helpers.production ? false : scripts,
is_production: helpers.production, is_production: helpers.production,
root: helpers.set('url full'), root: root,
static: helpers.set('static url'), static: helpers.urlForStatic(),
url: url, url: url,
live: req.live, live: req.live,
embed: req.embed, embed: req.embed,
Expand Down
3 changes: 2 additions & 1 deletion lib/helpers.js
Expand Up @@ -77,7 +77,8 @@ module.exports.createHelpers = function createHelpers(app) {
path = path.slice(1); path = path.slice(1);
} }


return app.set('static url') + '/' + (path || ''); var root = app.set('static url');
return path ? root + '/' + (path || '') : root;
} }
}; };
}; };

0 comments on commit 0f146f6

Please sign in to comment.