<commit_before>Meteor.startup ->
  if Meteor.isServer
    aglio = require('aglio')
    blueprintDoc = Assets.getText 'API.apib'
    blueprintDoc = blueprintDoc.replace 'http://localhost:3000/', process.env.ROOT_URL
    rendered = ''

    options =
      themeVariables: 'default'
      themeTemplate: 'triple'
      themeFullWidth: true
    aglio.render blueprintDoc, options, (err, html, warnings) ->
      rendered = html

    WebApp.connectHandlers.use "/api/v2/docs", (req, res, next) ->
      res.setHeader 'content-type', 'text/html; charset=utf-8'
      res.writeHead 200
      res.end rendered<commit_msg>check if ROOT_URL includes a trailing slash<commit_after>Meteor.startup ->
  if Meteor.isServer
    aglio = require('aglio')
    blueprintDoc = Assets.getText 'API.apib'
    console.log 'wawiewa', process.env.ROOT_URL[..1]
    url = "#{process.env.ROOT_URL}#{if process.env.ROOT_URL[process.env.ROOT_URL.length-1..-1] isnt '/' then '/' else ''}"
    blueprintDoc = blueprintDoc.replace 'http://localhost:3000/', url
    rendered = ''

    options =
      themeVariables: 'default'
      themeTemplate: 'triple'
      themeFullWidth: true
    aglio.render blueprintDoc, options, (err, html, warnings) ->
      rendered = html

    WebApp.connectHandlers.use "/docs/api/v2", (req, res, next) ->
      res.setHeader 'content-type', 'text/html; charset=utf-8'
      res.writeHead 200
      res.end rendered
{'fraction_non_alphanumeric': 0.13568904593639575, 'fraction_numerical': 0.014840989399293287, 'mean_word_length': 3.1403508771929824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3483668', 'n_tokens_mistral': 484, 'n_tokens_neox': 461, 'n_words': 96}