@quadrats/common 0.5.9 → 0.5.10
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.
|
@@ -6,17 +6,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
const PodcastAppleEmbedStrategy = {
|
|
7
7
|
serialize: (embedCode) => {
|
|
8
8
|
var _a, _b;
|
|
9
|
-
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/[\w-]
|
|
9
|
+
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode)) !== null && _a !== void 0 ? _a : /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/id([\d]*)/i.exec(embedCode)) !== null && _b !== void 0 ? _b : /^https:\/\/podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode);
|
|
10
10
|
if (result) {
|
|
11
|
-
const [, contextId] = result;
|
|
11
|
+
const [, language, contextId] = result;
|
|
12
12
|
return {
|
|
13
13
|
embedType: 'podcast-apple',
|
|
14
|
+
language,
|
|
14
15
|
contextId,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
|
-
deserialize:
|
|
19
|
-
isElementDataValid:
|
|
19
|
+
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
20
|
+
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
exports.PodcastAppleEmbedStrategy = PodcastAppleEmbedStrategy;
|
|
@@ -2,6 +2,7 @@ import { EmbedElement, EmbedStrategy } from '@quadrats/common/embed';
|
|
|
2
2
|
export declare type PodcastAppleEmbedType = 'podcast-apple';
|
|
3
3
|
export declare type PodcastAppleEmbedElementData = {
|
|
4
4
|
embedType: PodcastAppleEmbedType;
|
|
5
|
+
language?: string;
|
|
5
6
|
contextId: string;
|
|
6
7
|
};
|
|
7
8
|
export declare type PodcastAppleEmbedElement = EmbedElement & PodcastAppleEmbedElementData;
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
const PodcastAppleEmbedStrategy = {
|
|
3
3
|
serialize: (embedCode) => {
|
|
4
4
|
var _a, _b;
|
|
5
|
-
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/[\w-]
|
|
5
|
+
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode)) !== null && _a !== void 0 ? _a : /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/id([\d]*)/i.exec(embedCode)) !== null && _b !== void 0 ? _b : /^https:\/\/podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode);
|
|
6
6
|
if (result) {
|
|
7
|
-
const [, contextId] = result;
|
|
7
|
+
const [, language, contextId] = result;
|
|
8
8
|
return {
|
|
9
9
|
embedType: 'podcast-apple',
|
|
10
|
+
language,
|
|
10
11
|
contextId,
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
deserialize:
|
|
15
|
-
isElementDataValid:
|
|
15
|
+
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
16
|
+
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
export { PodcastAppleEmbedStrategy };
|