 				if opts and opts.idbName
 					db = opts.idbName
 				else
-					db = remoteDB.split("/").pop()
+					parts = remoteDB.split("/")
+					db = parts.pop()
+					while db == ""
+						db = parts.pop()
 		else
 			if opts and opts.idbName
 				db = opts.idbName
 			else
-				db = location.href.split("/").pop()
+				parts = location.href.split("/")
+				db = parts.pop()
+				while db == ""
+					db = parts.pop()
 		@_layers = {}
 		pouchParams = L.Util.extend({}, @defaultParams)
 		for i of opts

				@_from.cancel()
				@_to.cancel()
		cb(null, true)
	
)
L.geoJson.pouch = (db, remoteDB, opts)->
	new L.GeoJSON.Pouch(db, remoteDB, opts)
		direction: "from"

	initialize: (remoteDB, opts) ->
		@_orig = [remoteDB, opts]
		if typeof remoteDB is "object"
			opts = remoteDB
			remoteDB = undefined
