 			for route in routes
 				[type, label, ptrn] = route
 				
-				regEx = new RegExp  '^' + ptrn.replace(/\*/g, '([^/]*)') + '$'
-				console.log regEx
+				regEx = new RegExp '^' + ftnPath + '\\?u=/' + 
+						ptrn.replace(/\*/g, '([^/\?#]*)') + '/?(\\?([^#]*))?$'
+				@route regEx, 'n', _.bind urlChange, route
 				
-				path = ftnPath + '?u=/' + ptrn.replace /\*/g, ':x'
-				console.log path
-				@route path, 'n', _.bind urlChange, route
 			null
 	
 	urlRouter = new UrlRouter()

			bodyTxt = ''
			for key in @.model.get 'keys'
				bodyTxt += key + ': ' + @.model.get(key) + '<br>\n'
				
			$('#tabBody').html bodyTxt

	tabsView = new TabsView
		el: $('#tabRow')[0]
		model: urlModel
		
		
#	$.getJSON '/' + path, (doc, status) ->
#		return if not status is 'success' 
#		console.log 'getJSON: ', doc
#		editor.set doc

	
	
	buildUrl = (attrs) ->
		{ptrn: path, keys} = attrs
		for key in keys then path = path.replace /\*/, attrs[key]
		urlModel.set attrs
		
	
	urlChange = (parts...) ->
		[type, label, ptrn, keys...] = @

		console.log '--- URL: ', type, parts
		
		attrs = {type, label, ptrn, keys}
		for key, i in keys then attrs[key] = parts[i]
		
		buildUrl attrs
		

ftnPath = 'ftn/_design/ftn/index.html'

routes = [
#	['favicon', '', 'asdf']
#	
	['db',      'DB', 		'*', 					'db']
	['doc',     'Doc', 		'*/*', 					'db', 'doc'				]
	['attach',  'Attach', 	'*/*/*', 				'db', 'doc', 'attach'	]
	['des',     'Design', 	'*/_design/*', 			'db', 'design'			]
	['view',    'View', 	'*/_design/*/_view/*', 	'db', 'design', 'view'	]
]

$ -> 
	for route in routes
		[type, label, ptrn, keys...] = route
		if label
			dk.htmlOut = ''
