Merged v5.13.2 into main

v5.13.2
This commit is contained in:
Daniel Lockyer 2022-09-06 16:45:52 +01:00
commit 4a6f57b105
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
4 changed files with 27 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ghost-admin",
"version": "5.13.1",
"version": "5.13.2",
"description": "Ember.js admin client for Ghost",
"author": "Ghost Foundation",
"homepage": "http://ghost.org",

View File

@ -3,7 +3,7 @@
* @typedef {import('./oembed').IExternalRequest} IExternalRequest
*/
const OPENSEA_PATH_REGEX = /^\/assets\/(0x[a-f0-9]+)\/(\d+)/;
const OPENSEA_ETH_PATH_REGEX = /^\/assets\/ethereum\/(0x[a-f0-9]+)\/(\d+)/;
/**
* @implements ICustomProvider
@ -11,6 +11,8 @@ const OPENSEA_PATH_REGEX = /^\/assets\/(0x[a-f0-9]+)\/(\d+)/;
class NFTOEmbedProvider {
/**
* @param {object} dependencies
* @param {object} dependencies.config
* @param {string} [dependencies.config.apiKey] - An OpenSea API key
*/
constructor(dependencies) {
this.dependencies = dependencies;
@ -21,7 +23,7 @@ class NFTOEmbedProvider {
* @returns {Promise<boolean>}
*/
async canSupportRequest(url) {
return url.host === 'opensea.io' && OPENSEA_PATH_REGEX.test(url.pathname);
return url.host === 'opensea.io' && OPENSEA_ETH_PATH_REGEX.test(url.pathname);
}
/**
@ -31,7 +33,7 @@ class NFTOEmbedProvider {
* @returns {Promise<object>}
*/
async getOEmbedData(url, externalRequest) {
const [match, transaction, asset] = url.pathname.match(OPENSEA_PATH_REGEX);
const [match, transaction, asset] = url.pathname.match(OPENSEA_ETH_PATH_REGEX);
if (!match) {
return null;
}

View File

@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "5.13.1",
"version": "5.13.2",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",

View File

@ -0,0 +1,20 @@
const assert = require('assert');
const NFTOembedProvider = require('../../../../core/server/services/nft-oembed');
describe('NFTOEmbedProvider', function () {
it('Can support requests for OpenSea Ethereum NTFs', async function () {
const provider = new NFTOembedProvider({
config: {
apiKey: 'fake-api-key'
}
});
const ethereumNFTURL = new URL(
'https://opensea.io/assets/ethereum/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb/9998'
);
const supportsRequest = await provider.canSupportRequest(ethereumNFTURL);
assert(supportsRequest, 'Should support ethereum NFT URL');
});
});