-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor [Wordpress] services (#3324)
- Prefer inline transforms to take place in `handle()` rather than `render()` - Avoid inversion of control by removing `BaseWordpress#handle()`, passing `extensionType` into `fetch()`, and removing one layer of subclassing - Move “not found” checks into `fetch()` - Cache wordpress versions instead of fetching on each request - Start to convert aliases to redirects (there are more of these which could be tackled in a follow-on) - Replace at least one route `format` with a `pattern` (ref #3329) - Partially reorder: name, category, route, examples, defaultBadgeData, render, fetch, handle Some of this is in line with our established patterns or makes it clearly easier to follow; some of it is arguably stylistic.
- Loading branch information
1 parent
05af1f8
commit 5828223
Showing
9 changed files
with
205 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
const { redirector } = require('..') | ||
|
||
module.exports = redirector({ | ||
category: 'platform-support', | ||
route: { | ||
base: 'wordpress/v', | ||
pattern: ':slug', | ||
}, | ||
transformPath: ({ slug }) => `/wordpress/plugin/wp-version/${slug}`, | ||
dateAdded: new Date('2019-04-17'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
const t = (module.exports = require('../tester').createServiceTester()) | ||
|
||
t.create('Plugin Tested WP Version (Alias)') | ||
.get('/akismet.svg', { | ||
followRedirect: false, | ||
}) | ||
.expectStatus(301) | ||
.expectHeader('Location', '/wordpress/plugin/wp-version/akismet.svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.