<commit_before># TODO: Think about digests
helper 'computeAssetPath', (source, options = {}) ->
  options['type'] ||= 'asset'

  if H.forceAssetDomain
    options['domain'] ||= H.domain[ options['type'] ]

  format = if options['format'] == undefined
    H.defaultFormat[ options['type'] ]
  else
    options['format']

  if format
    sharp_index = source.lastIndexOf '#'
    query_index = source.lastIndexOf '?'

    index = if sharp_index == -1
      query_index
    else
      if query_index == -1
        sharp_index
      else
        if query_index > sharp_index
          sharp_index
        else
          query_index

    if index == -1
      source += '.' + format unless source[(-format.length-1)..-1] == ('.' + format)
    else
      prefix = source.slice 0, index
      sufix  = source.slice index
      if prefix[(-format.length-1)..-1] == ('.' + format)
        source = prefix + sufix
      else
        source = prefix + '.' + format + sufix

  source = if source[0] == '/'
    source
  else
    prefix_path = H.defaultPath[options['type']]
    if prefix_path[prefix_path.length-1] == '/'
      prefix_path + source
    else
      prefix_path + '/' + source

  source = '/' + source if source[0] != '/'

  if options['domain']
    source = options['domain'] + source

  source

helper 'assetPath', (source, options = {}) ->
  source  = source.toString()
  options = H._clone options

  fullDoaminPath = /[\w\d]+\:\/\//i
  return source if fullDoaminPath.test(source) || source[0..1] == '//'

  H.computeAssetPath source, options

helper 'assetUrl', (source, options = {}) ->
  source  = source.toString()
  options = H._clone options

  options['domain'] ||= if options['type']
    H.domain[options['type']] || H.domain.asset
  else
    H.domain.asset

  H.assetPath source, options

assetPathBuilder = (_type) ->
  type_built = _type
  (source, options = {}) ->
    options = H._clone options
    options['type'] = type_built if options['type'] == undefined
    H.assetPath source, options

assetUrlBuilder = (_type) ->
  type_built = _type
  (source, options = {}) ->
    options = H._clone options
    options['type'] = type_built if options['type'] == undefined
    H.assetUrl source, options

for index, type of ['audio', 'font', 'image', 'video', 'javascript', 'stylesheet']
  helper (type+'Path'), assetPathBuilder(type)
  helper (type+'Url'),  assetUrlBuilder(type)<commit_msg>Replaces H. to @ on AssetUrl helpers<commit_after># TODO: Think about digests
helper 'computeAssetPath', (source, options = {}) ->
  options['type'] ||= 'asset'

  if @forceAssetDomain
    options['domain'] ||= @domain[ options['type'] ]

  format = if options['format'] == undefined
    @defaultFormat[ options['type'] ]
  else
    options['format']

  if format
    sharp_index = source.lastIndexOf '#'
    query_index = source.lastIndexOf '?'

    index = if sharp_index == -1
      query_index
    else
      if query_index == -1
        sharp_index
      else
        if query_index > sharp_index
          sharp_index
        else
          query_index

    if index == -1
      source += '.' + format unless source[(-format.length-1)..-1] == ('.' + format)
    else
      prefix = source.slice 0, index
      sufix  = source.slice index
      if prefix[(-format.length-1)..-1] == ('.' + format)
        source = prefix + sufix
      else
        source = prefix + '.' + format + sufix

  source = if source[0] == '/'
    source
  else
    prefix_path = @defaultPath[options['type']]
    if prefix_path[prefix_path.length-1] == '/'
      prefix_path + source
    else
      prefix_path + '/' + source

  source = '/' + source if source[0] != '/'

  if options['domain']
    source = options['domain'] + source

  source

helper 'assetPath', (source, options = {}) ->
  source  = source.toString()
  options = @_clone options

  fullDoaminPath = /[\w\d]+\:\/\//i
  return source if fullDoaminPath.test(source) || source[0..1] == '//'

  @computeAssetPath source, options

helper 'assetUrl', (source, options = {}) ->
  source  = source.toString()
  options = @_clone options

  options['domain'] ||= if options['type']
    @domain[options['type']] || @domain.asset
  else
    @domain.asset

  @assetPath source, options

assetPathBuilder = (_type) ->
  type_built = _type
  (source, options = {}) ->
    options = @_clone options
    options['type'] = type_built if options['type'] == undefined
    @assetPath source, options

assetUrlBuilder = (_type) ->
  type_built = _type
  (source, options = {}) ->
    options = @_clone options
    options['type'] = type_built if options['type'] == undefined
    @assetUrl source, options

for index, type of ['audio', 'font', 'image', 'video', 'javascript', 'stylesheet']
  helper (type+'Path'), assetPathBuilder.call(this,type)
  helper (type+'Url'),  assetUrlBuilder.call(this,type)
{'fraction_non_alphanumeric': 0.15556474968969797, 'fraction_numerical': 0.005378568473314025, 'mean_word_length': 2.8897827835880934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '17853', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1494, 'n_words': 376}