ckeditor5 1.28.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c28d638338e7bdb2e029d6eb1a81a65126dfbe16b31828563e5d7a0efc3a51e
|
4
|
+
data.tar.gz: c87327aa99851db71ff50f0d12c606c58194b3840a4c13eb99e7ca22c6e87734
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 015fd8f7850a4620aa13d62c8ffee059a417fb8d6e2808f3699753843eb99eeb7c281ee03c949e0bf3458690a406d9854e56190bc0960dd1e2729f4ef56a008b
|
7
|
+
data.tar.gz: 914079678cd53137163f389df3d6a2a42992b7c1f9d84cdd6cd628b878973210eb442de79c5bea4b8cc7e01b0f05534afe0763fdd56534e3c4041c8703d20776
|
@@ -32,16 +32,34 @@ module CKEditor5::Rails::Assets
|
|
32
32
|
|
33
33
|
def to_json(*_args)
|
34
34
|
{
|
35
|
-
scripts: scripts.map(&:to_h),
|
36
|
-
stylesheets: stylesheets
|
35
|
+
scripts: unique_scripts(scripts).map(&:to_h),
|
36
|
+
stylesheets: unique_stylesheets(stylesheets)
|
37
37
|
}.to_json
|
38
38
|
end
|
39
39
|
|
40
40
|
def <<(other)
|
41
41
|
raise TypeError, 'other must be an instance of AssetsBundle' unless other.is_a?(AssetsBundle)
|
42
42
|
|
43
|
-
@scripts = scripts + other.scripts
|
44
|
-
@stylesheets = stylesheets + other.stylesheets
|
43
|
+
@scripts = unique_scripts(scripts + other.scripts)
|
44
|
+
@stylesheets = unique_stylesheets(stylesheets + other.stylesheets)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def unique_scripts(scripts_array)
|
50
|
+
with_url, without_url = scripts_array.partition { |script| script.respond_to?(:url) && script.url }
|
51
|
+
unique_with_url = with_url.uniq { |script| drop_version_from_url(script.url) }
|
52
|
+
unique_with_url + without_url
|
53
|
+
end
|
54
|
+
|
55
|
+
def unique_stylesheets(stylesheets_array)
|
56
|
+
stylesheets_array.uniq { |stylesheet| drop_version_from_url(stylesheet) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def drop_version_from_url(url)
|
60
|
+
url.to_s
|
61
|
+
.gsub(%r{/v?\d+\.\d+\.\d+(-[a-z0-9.]+)?/}, '/')
|
62
|
+
.gsub(%r{@\d+\.\d+\.\d+(-[a-z0-9.]+)?/?}, '')
|
45
63
|
end
|
46
64
|
end
|
47
65
|
|