@tryghost/url-utils 3.0.1 → 4.0.2

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.
Files changed (2) hide show
  1. package/lib/url-utils.js +6 -12
  2. package/package.json +4 -4
package/lib/url-utils.js CHANGED
@@ -70,15 +70,14 @@ module.exports = class UrlUtils {
70
70
  // Parameters:
71
71
  // - urlPath - string which must start and end with a slash
72
72
  // - absolute (optional, default:false) - boolean whether or not the url should be absolute
73
- // - secure (optional, default:false) - boolean whether or not to force SSL
74
73
  // Returns:
75
74
  // - a URL which always ends with a slash
76
- createUrl(urlPath = '/', absolute = false, secure, trailingSlash) {
75
+ createUrl(urlPath = '/', absolute = false, trailingSlash) {
77
76
  let base;
78
77
 
79
78
  // create base of url, always ends without a slash
80
79
  if (absolute) {
81
- base = this.getSiteUrl(secure);
80
+ base = this.getSiteUrl();
82
81
  } else {
83
82
  base = this.getSubdir();
84
83
  }
@@ -109,7 +108,6 @@ module.exports = class UrlUtils {
109
108
  // @TODO: rewrite, very hard to read, create private functions!
110
109
  urlFor(context, data, absolute) {
111
110
  let urlPath = '/';
112
- let secure;
113
111
  let imagePathRe;
114
112
  let knownObjects = ['image', 'nav'];
115
113
  let baseUrl;
@@ -127,9 +125,6 @@ module.exports = class UrlUtils {
127
125
  data = null;
128
126
  }
129
127
 
130
- // Can pass 'secure' flag in either context or data arg
131
- secure = (context && context.secure) || (data && data.secure);
132
-
133
128
  if (_.isObject(context) && context.relativeUrl) {
134
129
  urlPath = context.relativeUrl;
135
130
  } else if (_.isString(context) && _.indexOf(knownObjects, context) !== -1) {
@@ -141,15 +136,14 @@ module.exports = class UrlUtils {
141
136
  if (absolute) {
142
137
  // Remove the sub-directory from the URL because ghostConfig will add it back.
143
138
  urlPath = urlPath.replace(new RegExp('^' + this.getSubdir()), '');
144
- baseUrl = this.getSiteUrl(secure).replace(/\/$/, '');
139
+ baseUrl = this.getSiteUrl().replace(/\/$/, '');
145
140
  urlPath = baseUrl + urlPath;
146
141
  }
147
142
 
148
143
  return urlPath;
149
144
  } else if (context === 'nav' && data.nav) {
150
145
  urlPath = data.nav.url;
151
- secure = data.nav.secure || secure;
152
- baseUrl = this.getSiteUrl(secure);
146
+ baseUrl = this.getSiteUrl();
153
147
  hostname = baseUrl.split('//')[1];
154
148
 
155
149
  // If the hostname is present in the url
@@ -165,7 +159,7 @@ module.exports = class UrlUtils {
165
159
  }
166
160
  }
167
161
  } else if (context === 'home' && absolute) {
168
- urlPath = this.getSiteUrl(secure);
162
+ urlPath = this.getSiteUrl();
169
163
 
170
164
  // CASE: there are cases where urlFor('home') needs to be returned without trailing
171
165
  // slash e. g. the `{{@site.url}}` helper. See https://github.com/TryGhost/Ghost/issues/8569
@@ -210,7 +204,7 @@ module.exports = class UrlUtils {
210
204
  return urlPath;
211
205
  }
212
206
 
213
- return this.createUrl(urlPath, absolute, secure);
207
+ return this.createUrl(urlPath, absolute);
214
208
  }
215
209
 
216
210
  redirect301(res, redirectUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/url-utils",
3
- "version": "3.0.1",
3
+ "version": "4.0.2",
4
4
  "repository": "https://github.com/TryGhost/SDK/tree/master/packages/url-utils",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -19,8 +19,8 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
- "@tryghost/config-url-helpers": "0.1.8",
23
- "c8": "7.11.2",
22
+ "@tryghost/config-url-helpers": "1.0.1",
23
+ "c8": "7.11.3",
24
24
  "mocha": "10.0.0",
25
25
  "rewire": "6.0.0",
26
26
  "should": "13.2.3",
@@ -34,5 +34,5 @@
34
34
  "remark-footnotes": "^1.0.0",
35
35
  "unist-util-visit": "^2.0.0"
36
36
  },
37
- "gitHead": "2f7fb1fef3f2464f000974c8e0e13e25eabd6f6d"
37
+ "gitHead": "f5a8a2c81a4afc3640f922ef221ea1b6ddfa216a"
38
38
  }