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

fix for bug #454 on master branch, adds _isHTML condition at HTMLServer.js:151 #567 #568

Merged
merged 2 commits into from
Feb 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/extensions/default/bramble/nohost/HTMLServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,25 @@ define(function (require, exports, module) {
return callback(err);
}

// Since we're not instrumenting this doc fully for some reason,
// at least inject the scroll manager so we can track scroll position.
var scripts = MouseManager.getRemoteScript(path) + LinkManager.getRemoteScript();
var scriptsWithEndTag = scripts + "$&";
var headRegex = new RegExp(/<\/\s*head>/);
var htmlRegex = new RegExp(/<\/\s*html>/);

// Try to inject the scripts at the end of the <head> element
// if it is present
if(headRegex.test(content)) {
content = content.replace(headRegex, scriptsWithEndTag);
} else if(htmlRegex.test(content)) {
// Otherwise add them at the end of the <html> element
content = content.replace(htmlRegex, scriptsWithEndTag);
} else {
// Otherwise just add it at the end of the content
content += scripts;
if (_isHTML(path)) {
// Since we're not instrumenting this doc fully for some reason,
// at least inject the scroll manager so we can track scroll position.
var scripts = MouseManager.getRemoteScript(path) + LinkManager.getRemoteScript();
var scriptsWithEndTag = scripts + "$&";
var headRegex = new RegExp(/<\/\s*head>/);
var htmlRegex = new RegExp(/<\/\s*html>/);

// Try to inject the scripts at the end of the <head> element
// if it is present
if(headRegex.test(content)) {
content = content.replace(headRegex, scriptsWithEndTag);
} else if(htmlRegex.test(content)) {
// Otherwise add them at the end of the <html> element
content = content.replace(htmlRegex, scriptsWithEndTag);
} else {
// Otherwise just add it at the end of the content
content += scripts;
}
}

serve(content);
Expand Down