vidibus-permalink 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 515aa963b43b3d2cdf4576dfe00e9e8ddee3b819
4
- data.tar.gz: 5d7edb952308577f1d5b0a2893df325bf26d08c8
3
+ metadata.gz: ad640ae4ba877c077d2bc5fce555b80e53ce0031
4
+ data.tar.gz: 5f19f0c8dccc457029cdef8a96165d6ffe08317b
5
5
  SHA512:
6
- metadata.gz: eaf165cd78288a6cb4ab0933b4d1c82b6a13954637b0ebb5bbbcf1549187a9b80b370c15e3b56afea9057ea290066bb0018378c489ce584b43a97537d51a420b
7
- data.tar.gz: 426bb22b0fa89969a887b0efc58ba2b2d4b59b3ab3aeed27d8eab310cc203a3137f9555bbc7fd1bf2cd8be91e0c45f4332bfc1c7619b9a08bb6e116e16d65d64
6
+ metadata.gz: '0248ed6a753a7f733ee3427e9e06c247a49c0acf571caa11aad00bbc94cda1551cda1f362408151b68181e0ab30a58d087ca07b367c0f297d82b413077cd957e'
7
+ data.tar.gz: 5f9554a661f83a7ec6c7f38622676f8a2824c8dd49a4337d872165c75dd516667368bfcf2601dfc9abb7bc2c8ae38c17a226bea8f802cf08c5b9e0bb96b7e23a
@@ -66,9 +66,15 @@ class Permalink
66
66
 
67
67
  # Scope method for finding Permalinks for given value.
68
68
  # The value will be sanitized.
69
- def for_value(value, sanitize = true)
70
- value = sanitize(value) if sanitize
71
- where(value: /^#{value}(-\d+)?$/)
69
+ def for_value(value, do_sanitize = true)
70
+ if do_sanitize
71
+ self.or([
72
+ {value: /^#{sanitize(value)}(-\d+)?$/},
73
+ {value: /^#{sanitize(value, true)}(-\d+)?$/}
74
+ ])
75
+ else
76
+ where(value: /^#{value}(-\d+)?$/)
77
+ end
72
78
  end
73
79
 
74
80
  def for_scope(scope)
@@ -83,9 +89,10 @@ class Permalink
83
89
 
84
90
  # Sanitizes string: Remove stopwords and format as permalink.
85
91
  # See Vidibus::CoreExtensions::String for details.
86
- def sanitize(string)
92
+ def sanitize(string, keep_stopwords = false)
87
93
  return if string.blank?
88
- remove_stopwords(string).permalink
94
+ string = remove_stopwords(string) unless keep_stopwords
95
+ string.permalink
89
96
  end
90
97
 
91
98
  def scope_list(scope)
@@ -1,5 +1,5 @@
1
1
  module Vidibus
2
2
  module Permalink
3
- VERSION = '1.1.3'
3
+ VERSION = '1.1.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidibus-permalink
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Pankratz