<commit_before>var wompt = require("../includes"),
Util = wompt.util;

function NamespaceController(app){
	var express = app.express,
	self = this;
	this.namespaces = {};
	
	this.register = function(){
		//Lookup Chat namespaces in the namespace hash, and respond.
		express.get("*", function(req, res, next){
			var namespace_id = Util.extractFirstUrlPart(req),
			namespace = namespace_id && self.namespaces[namespace_id];
			
			if(namespace){
				namespace.handler.apply(this, arguments);
			}else
				next();
		});
	}


	this.createNamespace = function(namespace_id, options){
		app.namespaces = app.namespaces || {};
		otions = options || {};
		options.namespace = namespace_id;

		var	channelManager = new wompt.ChannelManager(options);
		
		app.namespaces[namespace_id] = channelManager;
		
		if(options.logged){
			new wompt.loggers.LoggerCreator(channelManager, namespace_id);
		}
		
		//if(options.fakeUsers) argumentsForGet.push(wompt.Auth.fake_user_middleware());
		
		function handleChatRoomGet(req, res){

			// Trim off ending slash
			if(req.url.substr(-1,1) == '/')
				return res.redirect(wompt.util.chop(req.url));
				
			// Trim of ending slash when we have query parameters
			if(req.url.indexOf('/?') >=0){
				req.url = req.url.replace('/?', '?');
				req.params[0] = wompt.util.chop(req.params[0]);
			}

			var meta_user = req.meta_user,
					channel = req.params[0];
					
			var token = wompt.Auth.get_or_set_token(req, res);

			var connector = app.client_connectors.add({
				meta_user:meta_user,
				namespace:channelManager,
				token: token
			});
			<commit_msg>Fix namespace issue: make sure a url like /namespace/room_name?iframe ends up a with a room named "room_name"<commit_after>var wompt = require("../includes"),
Util = wompt.util;

function NamespaceController(app){
	var express = app.express,
	self = this;
	this.namespaces = {};
	
	this.register = function(){
		//Lookup Chat namespaces in the namespace hash, and respond.
		express.get("/:namespace/*", function(req, res, next){
			var namespace_id = req.params.namespace,
			namespace = namespace_id && self.namespaces[namespace_id];
			
			if(namespace){
				req.params.room_name = req.params[0];
				namespace.handler.apply(this, arguments);
			}else
				next();
		});
	}

	this.createNamespace = function(namespace_id, options){
		app.namespaces = app.namespaces || {};
		options = options || {};
		options.namespace = namespace_id;

		var	channelManager = new wompt.ChannelManager(options);
		
		app.namespaces[namespace_id] = channelManager;
		
		if(options.logged){
			new wompt.loggers.LoggerCreator(channelManager, namespace_id);
		}
		
		//if(options.fakeUsers) argumentsForGet.push(wompt.Auth.fake_user_middleware());
		
		function handleChatRoomGet(req, res){

			// Trim off ending slash
			if(req.url.substr(-1,1) == '/')
				return res.redirect(wompt.util.chop(req.url));
				
			// Trim off ending slash when we have query parameters
			if(req.url.indexOf('/?') >=0){
				req.url = req.url.replace('/?', '?');
				req.params.room_name = wompt.util.chop(req.room_name);
			}

			var meta_user = req.meta_user,
					channel = req.params.room_name;
					
			var token = wompt.Auth.get_or_set_token(req, res);

			var connector = app.client_connectors.add({
				meta_user:meta_user,
				namespace:channelManager,
				token: token
			});
			
{'fraction_non_alphanumeric': 0.14238805970149254, 'fraction_numerical': 0.0029850746268656717, 'mean_word_length': 3.647711511789182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2252688', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1075, 'n_words': 220}