Index: js/FileAdaptor.js
===================================================================
--- js/FileAdaptor.js	(revision 5262)
+++ js/FileAdaptor.js	(working copy)
@@ -2,46 +2,51 @@
 //-- Server adaptor for talking to static TiddlyWiki files
 //--
 
-function FileAdaptor()
+function AdaptorBase()
 {
 	this.host = null;
 	this.store = null;
 	return this;
 }
 
-FileAdaptor.serverType = 'file';
-FileAdaptor.serverLabel = 'TiddlyWiki';
-
-FileAdaptor.prototype.setContext = function(context,userParams,callback)
+AdaptorBase.prototype.close = function()
 {
-	if(!context) context = {};
-	context.userParams = userParams;
-	if(callback) context.callback = callback;
-	context.adaptor = this;
-	if(!context.host)
-		context.host = this.host;
-	context.host = FileAdaptor.fullHostName(context.host);
-	if(!context.workspace)
-		context.workspace = this.workspace;
-	return context;
+	return true;
 };
 
-FileAdaptor.fullHostName = function(host)
+AdaptorBase.prototype.fullHostName = function(host)
 {
 	if(!host)
 		return '';
+	host = host.trim();
 	if(!host.match(/:\/\//))
 		host = 'http://' + host;
+	if(host.substr(host.length-1) != '/')
+		host = host + '/';
 	return host;
 };
 
-FileAdaptor.minHostName = function(host)
+AdaptorBase.minHostName = function(host)
 {
 	return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : '';
 };
 
+AdaptorBase.prototype.setContext = function(context,userParams,callback)
+{
+	if(!context) context = {};
+	context.userParams = userParams;
+	if(callback) context.callback = callback;
+	context.adaptor = this;
+	if(!context.host)
+		context.host = this.host;
+	context.host = this.fullHostName(context.host);
+	if(!context.workspace)
+		context.workspace = this.workspace;
+	return context;
+};
+
 // Open the specified host
-//#   host - url of host (eg, "http://www.tiddlywiki.com/" or "www.tiddlywiki.com")
+//#   host - uri of host (eg, "http://www.tiddlywiki.com/" or "www.tiddlywiki.com")
 //#   context is itself passed on as a parameter to the callback function
 //#   userParams - user settable object object that is passed on unchanged to the callback function
 //#   callback - optional function to be called on completion
@@ -51,7 +56,7 @@
 //#   context.status - true if OK, string if error
 //#   context.adaptor - reference to this adaptor object
 //#   userParams - parameters as originally passed into the openHost function
-FileAdaptor.prototype.openHost = function(host,context,userParams,callback)
+AdaptorBase.prototype.openHost = function(host,context,userParams,callback)
 {
 	this.host = host;
 	context = this.setContext(context,userParams,callback);
@@ -61,6 +66,35 @@
 	return true;
 };
 
+// Open the specified workspace
+//#   workspace - name of workspace to open
+//#   context - passed on as a parameter to the callback function
+//#   userParams - user settable object object that is passed on unchanged to the callback function
+//#   callback - function to be called on completion
+//# Return value is true if the request was successfully issued
+//#   or an error description string if there was a problem
+//# The callback parameters are callback(context,userParams)
+//#   context.status - true if OK, false if error
+//#   context.statusText - error message if there was an error
+//#   context.adaptor - reference to this adaptor object
+//#   userParams - parameters as originally passed into the openWorkspace function
+AdaptorBase.prototype.openWorkspace = function(workspace,context,userParams,callback)
+{
+	this.workspace = workspace;
+	context = this.setContext(context,userParams,callback);
+	context.status = true;
+	if(callback)
+		window.setTimeout(function() {callback(context,userParams);},10);
+	return true;
+};
+
+function FileAdaptor() {}
+
+FileAdaptor.prototype = new AdaptorBase();
+
+FileAdaptor.serverType = 'file';
+FileAdaptor.serverLabel = 'TiddlyWiki';
+
 FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr)
 {
 	context.status = status;
@@ -96,28 +130,6 @@
 	return true;
 };
 
-// Open the specified workspace
-//#   workspace - name of workspace to open
-//#   context - passed on as a parameter to the callback function
-//#   userParams - user settable object object that is passed on unchanged to the callback function
-//#   callback - function to be called on completion
-//# Return value is true if the request was successfully issued
-//#   or an error description string if there was a problem
-//# The callback parameters are callback(context,userParams)
-//#   context.status - true if OK, false if error
-//#   context.statusText - error message if there was an error
-//#   context.adaptor - reference to this adaptor object
-//#   userParams - parameters as originally passed into the openWorkspace function
-FileAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)
-{
-	this.workspace = workspace;
-	context = this.setContext(context,userParams,callback);
-	context.status = true;
-	if(callback)
-		window.setTimeout(function() {callback(context,userParams);},10);
-	return true;
-};
-
 // Gets the list of tiddlers within a given workspace
 //#   context - passed on as a parameter to the callback function
 //#   userParams - user settable object object that is passed on unchanged to the callback function
@@ -158,7 +170,7 @@
 		}
 		for(var i=0; i<context.tiddlers.length; i++) {
 			context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType;
-			context.tiddlers[i].fields['server.host'] = FileAdaptor.minHostName(context.host);
+			context.tiddlers[i].fields['server.host'] = AdaptorBase.minHostName(context.host);
 			context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM();
 		}
 		context.status = true;
@@ -203,7 +215,7 @@
 {
 	var t = context.adaptor.store.fetchTiddler(context.title);
 	t.fields['server.type'] = FileAdaptor.serverType;
-	t.fields['server.host'] = FileAdaptor.minHostName(context.host);
+	t.fields['server.host'] = AdaptorBase.minHostName(context.host);
 	t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM();
 	context.tiddler = t;
 	context.status = true;

