govuk_publishing_components 17.20.0 → 17.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +8 -0
  3. data/app/views/govuk_publishing_components/components/_subscription-links.html.erb +15 -5
  4. data/app/views/govuk_publishing_components/components/docs/subscription-links.yml +13 -2
  5. data/lib/govuk_publishing_components/version.rb +1 -1
  6. data/node_modules/accessible-autocomplete/package.json +1 -1
  7. data/node_modules/graceful-fs/package.json +13 -13
  8. data/node_modules/graceful-fs/polyfills.js +17 -11
  9. data/node_modules/hosted-git-info/CHANGELOG.md +40 -0
  10. data/node_modules/hosted-git-info/git-host-info.js +5 -3
  11. data/node_modules/hosted-git-info/git-host.js +35 -10
  12. data/node_modules/hosted-git-info/index.js +17 -15
  13. data/node_modules/hosted-git-info/package.json +40 -30
  14. data/node_modules/lru-cache/LICENSE +15 -0
  15. data/node_modules/lru-cache/README.md +166 -0
  16. data/node_modules/lru-cache/index.js +334 -0
  17. data/node_modules/lru-cache/package.json +108 -0
  18. data/node_modules/pkg-conf/package.json +1 -1
  19. data/node_modules/preact/debug.js +630 -2
  20. data/node_modules/preact/debug.js.map +1 -1
  21. data/node_modules/preact/debug/dist/debug.js +2 -0
  22. data/node_modules/preact/debug/dist/debug.js.map +1 -0
  23. data/node_modules/preact/debug/dist/debug.mjs +681 -0
  24. data/node_modules/preact/debug/dist/debug.mjs.map +1 -0
  25. data/node_modules/preact/debug/dist/debug.module.js +2 -0
  26. data/node_modules/preact/debug/dist/debug.module.js.map +1 -0
  27. data/node_modules/preact/debug/dist/debug.umd.js +2 -0
  28. data/node_modules/preact/debug/dist/debug.umd.js.map +1 -0
  29. data/node_modules/preact/debug/index.js +2 -1
  30. data/node_modules/preact/dist/preact.d.ts +808 -3
  31. data/node_modules/preact/dist/preact.dev.js +727 -727
  32. data/node_modules/preact/dist/preact.dev.js.map +1 -1
  33. data/node_modules/preact/dist/preact.js +1 -1
  34. data/node_modules/preact/dist/preact.js.flow +3 -3
  35. data/node_modules/preact/dist/preact.js.map +1 -1
  36. data/node_modules/preact/dist/preact.min.js +1 -1
  37. data/node_modules/preact/dist/preact.min.js.map +1 -1
  38. data/node_modules/preact/dist/preact.mjs +724 -724
  39. data/node_modules/preact/dist/preact.mjs.map +1 -1
  40. data/node_modules/preact/dist/preact.umd.js +751 -0
  41. data/node_modules/preact/dist/preact.umd.js.map +1 -0
  42. data/node_modules/preact/package.json +43 -26
  43. data/node_modules/preact/src/preact.d.ts +808 -3
  44. data/node_modules/preact/src/preact.js.flow +3 -3
  45. data/node_modules/preact/src/util.js +1 -1
  46. data/node_modules/yallist/LICENSE +15 -0
  47. data/node_modules/yallist/README.md +204 -0
  48. data/node_modules/yallist/iterator.js +8 -0
  49. data/node_modules/yallist/package.json +97 -0
  50. data/node_modules/yallist/yallist.js +376 -0
  51. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69db4a20c4227cb449798d0fe67a01931800d28a55d0cbc766d410229fae72c2
4
- data.tar.gz: ddc2cc361a5b702c810992ef0edfd7ea1ac2d7a25a15e3399b54fd48a83eace9
3
+ metadata.gz: e1032f24e05536ec9cc1ad6c774d9f5b6dd9dd05c86bcd9c3650a5adacb76e35
4
+ data.tar.gz: f5b6085f2fdd900a3f1fd6f917844f6939b72d51037ab9686abc0ddfaf6c2037
5
5
  SHA512:
6
- metadata.gz: 9273a260b4a1664e77857f00702c26280075295b194e6da42f379f72a415e2ce4d91138a41ef3e87af0b79f63ee5a9d1435ab6913c57e930ae98b1ed1a765d56
7
- data.tar.gz: e561e66924b798455aafc8c4ace7f506a2a001b166bb63ae6c62813e391feb26ff9fb4c47920d3fcba8d5e1f007ed00bdaa9a1ea886449ee32ca8b38df1ffff3
6
+ metadata.gz: e970106156e026f49a5b2fb6bd2ec36782f2a6dd0574e811b0976a91fd381c621daba3f9a2d8a14556236e9cb7b63d7122dae2cd814f5872be353eac43fd4d73
7
+ data.tar.gz: 646defcf886271c5b2b33d6103f350a90453bebb43c2f50bb5be60fde35806a9ff1efe404fd2f864ee108a1e498ad6d424a40ad2654c7074f5d54addc27222ba
@@ -3,3 +3,11 @@
3
3
  .gem-c-select__select--full-width {
4
4
  width: 100%;
5
5
  }
6
+
7
+ // Solution to text inside selects becoming unreadable if font size in
8
+ // the browser is increased. This is currently a problem in govuk-frontend
9
+ .gem-c-select {
10
+ .govuk-select {
11
+ height: 2.14em;
12
+ }
13
+ }
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  brand ||= false
3
3
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
4
+
4
5
  sl_helper = GovukPublishingComponents::Presenters::SubscriptionLinksHelper.new(local_assigns)
5
6
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
7
 
@@ -10,8 +11,13 @@
10
11
  css_classes = %w( gem-c-subscription-links )
11
12
  css_classes << (shared_helper.get_margin_bottom) unless local_assigns[:margin_bottom] == 0
12
13
  css_classes << brand_helper.brand_class
14
+
13
15
  data = {"module": "gem-toggle"} if sl_helper.feed_link_box_value
16
+
14
17
  hide_heading ||= false
18
+
19
+ email_signup_link_text_locale = local_assigns[:email_signup_link_text_locale]
20
+ feed_link_text_locale = local_assigns[:feed_link_text_locale]
15
21
  %>
16
22
  <% if sl_helper.component_data_is_valid? %>
17
23
  <%= tag.section class: css_classes, data: data do %>
@@ -25,10 +31,11 @@
25
31
  <% if sl_helper.email_signup_link.present? %>
26
32
  <li class="gem-c-subscription-links__list-item<%= ' gem-c-subscription-links__list-item--small' if local_assigns[:small_form] == true %>" >
27
33
  <svg xmlns="http://www.w3.org/2000/svg" width="21" height="15.75" class="gem-c-subscription-links__icon" focusable="false" fill="currentColor" aria-hidden="true"><path d="M19.687 0H1.312C.589 0 0 .587 0 1.313v13.124c0 .726.588 1.313 1.313 1.313h18.374c.725 0 1.313-.587 1.313-1.313V1.313C21 .587 20.412 0 19.687 0zm-2.625 2.625L10.5 7.875l-6.563-5.25h13.126zm1.313 10.5H2.625V3.937L10.5 10.5l7.875-6.563v9.188z"/></svg>
28
- <%= link_to sl_helper.email_signup_link_text, sl_helper.email_signup_link,
34
+ <%= link_to sl_helper.email_signup_link_text, sl_helper.email_signup_link, {
29
35
  class: "gem-c-subscription-links__link #{brand_helper.color_class}",
30
- data: sl_helper.email_signup_link_data_attributes
31
- %>
36
+ data: sl_helper.email_signup_link_data_attributes,
37
+ lang: email_signup_link_text_locale
38
+ } %>
32
39
  </li>
33
40
  <% end %>
34
41
 
@@ -36,8 +43,11 @@
36
43
  <li class="gem-c-subscription-links__list-item<%= ' gem-c-subscription-links__list-item--small' if local_assigns[:small_form] == true %>">
37
44
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" class="gem-c-subscription-links__icon" focusable="false" fill="currentColor" aria-hidden="true"><path d="M1.996 11A2 2 0 0 0 0 12.993c0 1.101.895 1.99 1.996 1.99 1.106 0 2-.889 2-1.99a2 2 0 0 0-2-1.993zM.002 5.097V7.97c1.872 0 3.632.733 4.958 2.059A6.984 6.984 0 0 1 7.015 15h2.888c0-5.461-4.443-9.903-9.9-9.903zM.006 0v2.876c6.676 0 12.11 5.44 12.11 12.124H15C15 6.731 8.273 0 .006 0z"/></svg>
38
45
  <%= link_to sl_helper.feed_link_text, sl_helper.feed_link,
39
- class: "gem-c-subscription-links__link #{brand_helper.color_class}",
40
- data: sl_helper.feed_link_data_attributes
46
+ {
47
+ class: "gem-c-subscription-links__link #{brand_helper.color_class}",
48
+ data: sl_helper.feed_link_data_attributes,
49
+ lang: feed_link_text_locale
50
+ }
41
51
  %>
42
52
  </li>
43
53
  <% end %>
@@ -81,9 +81,20 @@ examples:
81
81
  small_form: true
82
82
  without_heading:
83
83
  description: |
84
- By default the component includes an h2 heading. The component could be used anywhere on the page and could mean
85
- that it produces invalid markup or make the site unaccessible.
84
+ By default the component includes an h2 heading. The component could be used anywhere on the page and could mean that it produces invalid markup or make the site unaccessible.
86
85
  data:
87
86
  email_signup_link: '/foreign-travel-advice/singapore/email-signup'
88
87
  feed_link: '/foreign-travel-advice/singapore.atom'
89
88
  hide_heading: true
89
+ with_a_different_language:
90
+ data:
91
+ email_signup_link: '/foreign-travel-advice/singapore/email-signup'
92
+ email_signup_link_text: 'Recevez des notifications'
93
+ email_signup_link_text_locale: 'fr'
94
+ feed_link: '/foreign-travel-advice/singapore.atom'
95
+ feed_link_text: 'Flux RSS'
96
+ feed_link_text_locale: 'fr'
97
+ description: |
98
+ The component is used on translated pages that don't have a translation for the text strings. This means that it could display the fallback English string if the translate method can't find an appropriate translation. This makes sure that the `lang` can be set to ensure that browsers understand which parts of the page are in each language.
99
+
100
+ The `lang` attribute **must** be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is `en` or `eng`, Korean is `ko` or `kor` - but if in doubt please check.
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '17.20.0'.freeze
2
+ VERSION = '17.21.0'.freeze
3
3
  end
@@ -49,7 +49,7 @@
49
49
  "/"
50
50
  ],
51
51
  "_resolved": "git://github.com/alphagov/accessible-autocomplete.git#3523dd9fffc70cbd9f6f555f75863c33a709f49e",
52
- "_shasum": "093dd9034fc7b0c7da40a226cad47c62d9bbe6d6",
52
+ "_shasum": "e84aa32f47a3675f17c583385901d70c398b19d2",
53
53
  "_shrinkwrap": null,
54
54
  "_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
55
55
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
@@ -15,19 +15,19 @@
15
15
  ],
16
16
  "_from": "graceful-fs@>=4.1.2 <5.0.0",
17
17
  "_hasShrinkwrap": false,
18
- "_id": "graceful-fs@4.2.0",
18
+ "_id": "graceful-fs@4.2.1",
19
19
  "_inCache": true,
20
20
  "_location": "/graceful-fs",
21
- "_nodeVersion": "12.4.0",
21
+ "_nodeVersion": "12.6.0",
22
22
  "_npmOperationalInternal": {
23
23
  "host": "s3://npm-registry-packages",
24
- "tmp": "tmp/graceful-fs_4.2.0_1561577965134_0.17208797293985856"
24
+ "tmp": "tmp/graceful-fs_4.2.1_1564898680936_0.4561090715904119"
25
25
  },
26
26
  "_npmUser": {
27
27
  "name": "isaacs",
28
28
  "email": "i@izs.me"
29
29
  },
30
- "_npmVersion": "6.9.0",
30
+ "_npmVersion": "6.10.2",
31
31
  "_phantomChildren": {},
32
32
  "_requested": {
33
33
  "raw": "graceful-fs@^4.1.2",
@@ -45,8 +45,8 @@
45
45
  "/load-json-file",
46
46
  "/pkg-conf/load-json-file"
47
47
  ],
48
- "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
49
- "_shasum": "8d8fdc73977cb04104721cb53666c1ca64cd328b",
48
+ "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.1.tgz",
49
+ "_shasum": "1c1f0c364882c868f5bff6512146328336a11b1d",
50
50
  "_shrinkwrap": null,
51
51
  "_spec": "graceful-fs@^4.1.2",
52
52
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/flat-cache",
@@ -65,14 +65,14 @@
65
65
  "test": "test"
66
66
  },
67
67
  "dist": {
68
- "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==",
69
- "shasum": "8d8fdc73977cb04104721cb53666c1ca64cd328b",
70
- "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
68
+ "integrity": "sha512-b9usnbDGnD928gJB3LrCmxoibr3VE4U2SMo5PBuBnokWyDADTqDPXg4YpwKF1trpH+UbGp7QLicO3+aWEy0+mw==",
69
+ "shasum": "1c1f0c364882c868f5bff6512146328336a11b1d",
70
+ "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.1.tgz",
71
71
  "fileCount": 7,
72
- "unpackedSize": 26173,
73
- "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdE8ntCRA9TVsSAnZWagAAhkMP/1wpAg/eCBxcFvsgN55w\n3WotZ+6HJqOB+j5nNC0s78Pqc4E+g9VXNuvKVXlDyx7DwXudJgwY3L2hnmVX\nLItj62qFJ3Zn5KayYsYKnUEWM5/I1iYyExsy+6aQs2KfEAqnQgjcSA3ZN+Pf\nmVLv5NGrtrA/erF8CFjMtApK4GggPSZYjWV8ykWGoZTen67QBbQbwygooM13\ncvfXrVUA80lR00/Yy9pFZcjfijt/2jW427t6LxpevrONA4dviVWg8R+l02Gm\nnrIpvCoqt+FWtnBtJu/K+nORmFdpvetixhNkZY0DDJ+FBW1Qqg5pVHkpcXF+\ngTSGJpGvt2p04y5ZXPNnBx7mL37Nt9zblHnY4tJpzDXE11RSnrRc59cE/6UK\nS58TpbUrNdTNgYH9I0KkLXQ7zWgl1TxUDhEtyOAIH97M8z7XYblGLViv5pQT\nPTJnG61H5EVMC5AJKgnImPhpoS5kofNdp8oKOPQ+2GwsITwNv/RJi/86/3GR\n1QlFu4oW6E/tCg3KkskL3KN04Ohgm3rdJZUXG5t/cQTiGlk0H1CVjDiG/yMW\nWOIpO8EAuN7MkCukI4rKgYhR3BxzJ+N1tdw0sSb80x9/6JmUh9Bl4pZvdH2V\naWVdsJX/KoT6xjwiX5vi8p0fCIQswggUKAvRVygKDKuhKz+ubbtbXtQFwuJF\nwsmn\r\n=YcR0\r\n-----END PGP SIGNATURE-----\r\n"
72
+ "unpackedSize": 26326,
73
+ "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdRnV5CRA9TVsSAnZWagAAI+cP/09vQFDgflZI5LDhq7Kn\nPzOQDHXsrAHDvKW1F55RxTFIXjPqExI8byFKOsPRDmeK/grBCEiovq3YGig/\nqC/HpiPuxWBo5WoOqScn7nuvbqN5vtAGjSbA9XN1nQHG+yFLv4A9V6/U6YCi\nVMcwIq4J3FzciBWGQ78R4DvmeCLyKCEXoxxQsHNl8+qrWtnrNF2rWvab4dtV\nypHI6HY2DdI5Lx/trflzyrKe3ycS6SiD+oJ+exxL/YewB4xHHftxVhALUoGS\nyT6AVg4vWz/LWdE2M4IG4jzjb9Mk3bBlpODIc1AlfDib5RHQ62oH9roQiq5A\nYKSWQ4BfOdz/c1c+YjXVEkCaSG5IKd9ULq2I/awfI714sy0CMsdFino29umN\nUODANsl9nrk8RGJ65lIKZVeF4EGFKHF7CcbuBpO5AkMKf32/uIXTkprUWrO4\nMVoaxp5HXasSp8fH1y9CryITWwdgFksnFrlgnUL3l6AaNWzLTajEWQmzeVdj\n3ADQ/GglE6bxJMnMzaD2c5KbS3+CnpqKxIqPbiPFtjyJeNGQCjKx/PgXDsp7\nmNo3KAcbTFYBjc/34sczullnv95TGCZOm6Oyz8XncI1afKqdTPBztf6MXmXl\nNKs+Z2k/p4o95MyLTwHBzRAZfXUhA87StuFijMJhyVD5JPx1Ja88ItqoLzog\nJWsf\r\n=Oyod\r\n-----END PGP SIGNATURE-----\r\n"
74
74
  },
75
- "gitHead": "585df780323740a2b562677caa08a80de1f56c62",
75
+ "gitHead": "7e8a5605310d1f995d56dcc2690660c58e5554b0",
76
76
  "homepage": "https://github.com/isaacs/node-graceful-fs#readme",
77
77
  "keywords": [
78
78
  "fs",
@@ -111,5 +111,5 @@
111
111
  "preversion": "npm test",
112
112
  "test": "node test.js | tap -"
113
113
  },
114
- "version": "4.2.0"
114
+ "version": "4.2.1"
115
115
  }
@@ -115,20 +115,26 @@ function patch (fs) {
115
115
  }
116
116
 
117
117
  // if read() returns EAGAIN, then just try it again.
118
- fs.read = (function (fs$read) { return function (fd, buffer, offset, length, position, callback_) {
119
- var callback
120
- if (callback_ && typeof callback_ === 'function') {
121
- var eagCounter = 0
122
- callback = function (er, _, __) {
123
- if (er && er.code === 'EAGAIN' && eagCounter < 10) {
124
- eagCounter ++
125
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
118
+ fs.read = (function (fs$read) {
119
+ function read (fd, buffer, offset, length, position, callback_) {
120
+ var callback
121
+ if (callback_ && typeof callback_ === 'function') {
122
+ var eagCounter = 0
123
+ callback = function (er, _, __) {
124
+ if (er && er.code === 'EAGAIN' && eagCounter < 10) {
125
+ eagCounter ++
126
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
127
+ }
128
+ callback_.apply(this, arguments)
126
129
  }
127
- callback_.apply(this, arguments)
128
130
  }
131
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
129
132
  }
130
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
131
- }})(fs.read)
133
+
134
+ // This ensures `util.promisify` works as it does for native `fs.read`.
135
+ read.__proto__ = fs$read
136
+ return read
137
+ })(fs.read)
132
138
 
133
139
  fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
134
140
  var eagCounter = 0
@@ -2,6 +2,46 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ <a name="2.8.2"></a>
6
+ ## [2.8.2](https://github.com/npm/hosted-git-info/compare/v2.8.1...v2.8.2) (2019-08-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * http protocol use sshurl by default ([3b1d629](https://github.com/npm/hosted-git-info/commit/3b1d629)), closes [#48](https://github.com/npm/hosted-git-info/issues/48)
12
+
13
+
14
+
15
+ <a name="2.8.1"></a>
16
+ ## [2.8.1](https://github.com/npm/hosted-git-info/compare/v2.8.0...v2.8.1) (2019-08-05)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * ignore noCommittish on tarball url generation ([5d4a8d7](https://github.com/npm/hosted-git-info/commit/5d4a8d7))
22
+ * use gist tarball url that works for anonymous gists ([1692435](https://github.com/npm/hosted-git-info/commit/1692435))
23
+
24
+
25
+
26
+ <a name="2.8.0"></a>
27
+ # [2.8.0](https://github.com/npm/hosted-git-info/compare/v2.7.1...v2.8.0) (2019-08-05)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * Allow slashes in gitlab project section ([bbcf7b2](https://github.com/npm/hosted-git-info/commit/bbcf7b2)), closes [#46](https://github.com/npm/hosted-git-info/issues/46) [#43](https://github.com/npm/hosted-git-info/issues/43)
33
+ * **git-host:** disallow URI-encoded slash (%2F) in `path` ([3776fa5](https://github.com/npm/hosted-git-info/commit/3776fa5)), closes [#44](https://github.com/npm/hosted-git-info/issues/44)
34
+ * **gitlab:** Do not URL encode slashes in project name for GitLab https URL ([cbf04f9](https://github.com/npm/hosted-git-info/commit/cbf04f9)), closes [#47](https://github.com/npm/hosted-git-info/issues/47)
35
+ * do not allow invalid gist urls ([d5cf830](https://github.com/npm/hosted-git-info/commit/d5cf830))
36
+ * **cache:** Switch to lru-cache to save ourselves from unlimited memory consumption ([e518222](https://github.com/npm/hosted-git-info/commit/e518222)), closes [#38](https://github.com/npm/hosted-git-info/issues/38)
37
+
38
+
39
+ ### Features
40
+
41
+ * give these objects a name ([60abaea](https://github.com/npm/hosted-git-info/commit/60abaea))
42
+
43
+
44
+
5
45
  <a name="2.7.1"></a>
6
46
  ## [2.7.1](https://github.com/npm/hosted-git-info/compare/v2.7.0...v2.7.1) (2018-07-07)
7
47
 
@@ -23,12 +23,14 @@ var gitHosts = module.exports = {
23
23
  'domain': 'gitlab.com',
24
24
  'treepath': 'tree',
25
25
  'bugstemplate': 'https://{domain}/{user}/{project}/issues',
26
- 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
26
+ 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}',
27
+ 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}',
28
+ 'pathmatch': /^[/]([^/]+)[/](.+?)(?:[.]git|[/])?$/
27
29
  },
28
30
  gist: {
29
31
  'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
30
32
  'domain': 'gist.github.com',
31
- 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
33
+ 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]{32,})(?:[.]git)?$/,
32
34
  'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
33
35
  'bugstemplate': 'https://{domain}/{project}',
34
36
  'gittemplate': 'git://{domain}/{project}.git{#committish}',
@@ -40,7 +42,7 @@ var gitHosts = module.exports = {
40
42
  'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
41
43
  'shortcuttemplate': '{type}:{project}{#committish}',
42
44
  'pathtemplate': '{project}{#committish}',
43
- 'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz',
45
+ 'tarballtemplate': 'https://codeload.github.com/gist/{project}/tar.gz/{committish}',
44
46
  'hashformat': function (fragment) {
45
47
  return 'file-' + formatHashFragment(fragment)
46
48
  }
@@ -1,9 +1,24 @@
1
1
  'use strict'
2
2
  var gitHosts = require('./git-host-info.js')
3
3
  /* eslint-disable node/no-deprecated-api */
4
- var extend = Object.assign || require('util')._extend
5
4
 
6
- var GitHost = module.exports = function (type, user, auth, project, committish, defaultRepresentation, opts) {
5
+ // copy-pasta util._extend from node's source, to avoid pulling
6
+ // the whole util module into peoples' webpack bundles.
7
+ /* istanbul ignore next */
8
+ var extend = Object.assign || function _extend (target, source) {
9
+ // Don't do anything if source isn't an object
10
+ if (source === null || typeof source !== 'object') return target
11
+
12
+ const keys = Object.keys(source)
13
+ let i = keys.length
14
+ while (i--) {
15
+ target[keys[i]] = source[keys[i]]
16
+ }
17
+ return target
18
+ }
19
+
20
+ module.exports = GitHost
21
+ function GitHost (type, user, auth, project, committish, defaultRepresentation, opts) {
7
22
  var gitHostInfo = this
8
23
  gitHostInfo.type = type
9
24
  Object.keys(gitHosts[type]).forEach(function (key) {
@@ -16,7 +31,6 @@ var GitHost = module.exports = function (type, user, auth, project, committish,
16
31
  gitHostInfo.default = defaultRepresentation
17
32
  gitHostInfo.opts = opts || {}
18
33
  }
19
- GitHost.prototype = {}
20
34
 
21
35
  GitHost.prototype.hash = function () {
22
36
  return this.committish ? '#' + this.committish : ''
@@ -32,24 +46,33 @@ GitHost.prototype._fill = function (template, opts) {
32
46
  if (self[key] != null && vars[key] == null) vars[key] = self[key]
33
47
  })
34
48
  var rawAuth = vars.auth
35
- var rawComittish = vars.committish
49
+ var rawcommittish = vars.committish
36
50
  var rawFragment = vars.fragment
37
51
  var rawPath = vars.path
52
+ var rawProject = vars.project
38
53
  Object.keys(vars).forEach(function (key) {
39
- vars[key] = encodeURIComponent(vars[key])
54
+ var value = vars[key]
55
+ if ((key === 'path' || key === 'project') && typeof value === 'string') {
56
+ vars[key] = value.split('/').map(function (pathComponent) {
57
+ return encodeURIComponent(pathComponent)
58
+ }).join('/')
59
+ } else {
60
+ vars[key] = encodeURIComponent(value)
61
+ }
40
62
  })
41
63
  vars['auth@'] = rawAuth ? rawAuth + '@' : ''
42
64
  vars['#fragment'] = rawFragment ? '#' + this.hashformat(rawFragment) : ''
43
65
  vars.fragment = vars.fragment ? vars.fragment : ''
44
66
  vars['#path'] = rawPath ? '#' + this.hashformat(rawPath) : ''
45
67
  vars['/path'] = vars.path ? '/' + vars.path : ''
68
+ vars.projectPath = rawProject.split('/').map(encodeURIComponent).join('/')
46
69
  if (opts.noCommittish) {
47
70
  vars['#committish'] = ''
48
71
  vars['/tree/committish'] = ''
49
- vars['/comittish'] = ''
50
- vars.comittish = ''
72
+ vars['/committish'] = ''
73
+ vars.committish = ''
51
74
  } else {
52
- vars['#committish'] = rawComittish ? '#' + rawComittish : ''
75
+ vars['#committish'] = rawcommittish ? '#' + rawcommittish : ''
53
76
  vars['/tree/committish'] = vars.committish
54
77
  ? '/' + vars.treepath + '/' + vars.committish
55
78
  : ''
@@ -114,7 +137,8 @@ GitHost.prototype.path = function (opts) {
114
137
  return this._fill(this.pathtemplate, opts)
115
138
  }
116
139
 
117
- GitHost.prototype.tarball = function (opts) {
140
+ GitHost.prototype.tarball = function (opts_) {
141
+ var opts = extend({}, opts_, { noCommittish: false })
118
142
  return this._fill(this.tarballtemplate, opts)
119
143
  }
120
144
 
@@ -127,5 +151,6 @@ GitHost.prototype.getDefaultRepresentation = function () {
127
151
  }
128
152
 
129
153
  GitHost.prototype.toString = function (opts) {
130
- return (this[this.default] || this.sshurl).call(this, opts)
154
+ if (this.default && typeof this[this.default] === 'function') return this[this.default](opts)
155
+ return this.sshurl(opts)
131
156
  }
@@ -2,17 +2,18 @@
2
2
  var url = require('url')
3
3
  var gitHosts = require('./git-host-info.js')
4
4
  var GitHost = module.exports = require('./git-host.js')
5
+ var LRU = require('lru-cache')
6
+ var cache = new LRU({max: 1000})
5
7
 
6
8
  var protocolToRepresentationMap = {
7
- 'git+ssh': 'sshurl',
8
- 'git+https': 'https',
9
- 'ssh': 'sshurl',
10
- 'git': 'git'
9
+ 'git+ssh:': 'sshurl',
10
+ 'git+https:': 'https',
11
+ 'ssh:': 'sshurl',
12
+ 'git:': 'git'
11
13
  }
12
14
 
13
15
  function protocolToRepresentation (protocol) {
14
- if (protocol.substr(-1) === ':') protocol = protocol.slice(0, -1)
15
- return protocolToRepresentationMap[protocol] || protocol
16
+ return protocolToRepresentationMap[protocol] || protocol.slice(0, -1)
16
17
  }
17
18
 
18
19
  var authProtocols = {
@@ -23,17 +24,15 @@ var authProtocols = {
23
24
  'git+http:': true
24
25
  }
25
26
 
26
- var cache = {}
27
-
28
27
  module.exports.fromUrl = function (giturl, opts) {
29
28
  if (typeof giturl !== 'string') return
30
29
  var key = giturl + JSON.stringify(opts || {})
31
30
 
32
- if (!(key in cache)) {
33
- cache[key] = fromUrl(giturl, opts)
31
+ if (!cache.has(key)) {
32
+ cache.set(key, fromUrl(giturl, opts))
34
33
  }
35
34
 
36
- return cache[key]
35
+ return cache.get(key)
37
36
  }
38
37
 
39
38
  function fromUrl (giturl, opts) {
@@ -65,13 +64,17 @@ function fromUrl (giturl, opts) {
65
64
  var pathmatch = gitHostInfo.pathmatch
66
65
  var matched = parsed.path.match(pathmatch)
67
66
  if (!matched) return
68
- if (matched[1] != null) user = decodeURIComponent(matched[1].replace(/^:/, ''))
69
- if (matched[2] != null) project = decodeURIComponent(matched[2])
67
+ if (matched[1] !== null && matched[1] !== undefined) {
68
+ user = decodeURIComponent(matched[1].replace(/^:/, ''))
69
+ }
70
+ project = decodeURIComponent(matched[2])
70
71
  defaultRepresentation = protocolToRepresentation(parsed.protocol)
71
72
  }
72
73
  return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation, opts)
73
74
  } catch (ex) {
74
- if (!(ex instanceof URIError)) throw ex
75
+ /* istanbul ignore else */
76
+ if (ex instanceof URIError) {
77
+ } else throw ex
75
78
  }
76
79
  }).filter(function (gitHostInfo) { return gitHostInfo })
77
80
  if (matches.length !== 1) return
@@ -101,7 +104,6 @@ function fixupUnqualifiedGist (giturl) {
101
104
  }
102
105
 
103
106
  function parseGitUrl (giturl) {
104
- if (typeof giturl !== 'string') giturl = '' + giturl
105
107
  var matched = giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
106
108
  if (!matched) return url.parse(giturl)
107
109
  return {