Sha256: aae9362a34f47b1565d2f96e2e3a6c59f8e3f5fc836a2552d46659476eb50b94

Contents?: true

Size: 621 Bytes

Versions: 9

Compression:

Stored size: 621 Bytes

Contents

u = up.util

class up.UrlSet

  constructor: (@urls, options = {}) ->
    @normalizeUrl = options.normalizeUrl || u.normalizeUrl
    @urls = u.map(@urls, @normalizeUrl)
    @urls = u.compact(@urls)

  matches: (testUrl) =>
    if testUrl.substr(-1) == '*'
      @doesMatchPrefix(testUrl.slice(0, -1))
    else
      @doesMatchFully(testUrl)

  doesMatchFully: (testUrl) =>
    u.contains(@urls, testUrl)

  doesMatchPrefix: (prefix) =>
    u.detect @urls, (url) ->
      url.indexOf(prefix) == 0

  matchesAny: (testUrls) =>
    u.detect(testUrls, @matches)

  isEqual: (otherSet) =>
    u.isEqual(@urls, otherSet?.urls)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
unpoly-rails-0.57.0 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.7 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.6 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.5 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.4 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.3 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.2 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.1 lib/assets/javascripts/unpoly/classes/url_set.coffee
unpoly-rails-0.56.0 lib/assets/javascripts/unpoly/classes/url_set.coffee