<commit_before>var server = require('./server')()
var client = require('./')
var tape = require('tape')

server.listen(9000, function () {
  tape('subscribe', function (t) {
    var c = client('app', ['localhost:9000'])

    c.subscribe('hello').on('data', function (message) {
      t.same(message, {hello: 'world'})
      t.end()
      this.destroy()
    }).on('open', function () {
      c.broadcast('hello', {hello: 'world'})
    })

  })

  tape('subscribe with trailing /', function (t) {
    var c = client('app', ['localhost:9000/'])

    c.subscribe('hello').on('data', function (message) {
      t.same(message, {hello: 'world'})
      t.end()
      this.destroy()
    }).on('open', function () {
      c.broadcast('hello', {hello: 'world'})
    })

  })

  tape('subscribe to many', function (t) {
    var c = client('app', ['localhost:9000'])
    var msgs = ['stranger', 'friend']

    c.subscribe(['hello', 'goodbye']).on('data', function (message) {
      t.same(message, {msg: msgs.shift()})
      if (msgs.length === 0) {
        t.end()
        this.destroy()
      }
    }).on('open', function () {
      c.broadcast('hello', { msg: msgs[0]})
      c.broadcast('goodbye', { msg: msgs[1]})
    })
  })

  tape('subscribe to channels with slash in the name', function (t) {
    var c = client('app', ['localhost:9000'])<commit_msg>support trailing / in url and fix tests<commit_after>var server = require('./server')()
var client = require('./')
var tape = require('tape')

server.listen(9000, function () {
  tape('subscribe', function (t) {
    var c = client('app', ['localhost:9000'])

    c.subscribe('hello').on('data', function (message) {
      t.same(message, {hello: 'world'})
      t.end()
      this.destroy()
    }).on('open', function () {
      c.broadcast('hello', {hello: 'world'})
    })

  })

  tape('subscribe with trailing /', function (t) {
    var c = client('app', ['localhost:9000/'])

    c.subscribe('hello').on('data', function (message) {
      t.same(message, {hello: 'world'})
      t.end()
      this.destroy()
    }).on('open', function () {
      c.broadcast('hello', {hello: 'world'})
    })

  })

  tape('subscribe to many', function (t) {
    var c = client('app', ['localhost:9000'])
    var msgs = ['stranger', 'friend']

    c.subscribe(['hello', 'goodbye']).on('data', function (message) {
      t.same(message, {msg: msgs.shift()})
      if (msgs.length === 0) {
        t.end()
        this.destroy()
      }
    }).on('open', function () {
      c.broadcast('hello', { msg: 'stranger'}, function () {
        c.broadcast('goodbye', { msg: 'friend'})
      })
    })
  })

  tape('subscribe to channels with slash in the name', function (t) {
    var c = client('app', ['localhost:9000'])
{'fraction_non_alphanumeric': 0.21753364859949073, 'fraction_numerical': 0.01600582029829029, 'mean_word_length': 2.945480631276901, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4947572', 'n_tokens_mistral': 940, 'n_tokens_neox': 907, 'n_words': 206}