Skip to content

Commit 721a34c

Browse files
committed
fix branch link on demo
1 parent bcef387 commit 721a34c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

demo/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
/* global $, Hls */
1+
/* global $, Hls, __NETLIFY__ */
22
/* eslint camelcase: 0 */
33

44
import { sortObject, copyTextToClipboard } from './demo-utils';
55
import { TimelineChart } from './chart/timeline-chart';
66

7+
const NETLIFY = __NETLIFY__; // replaced in build
8+
79
const STORAGE_KEYS = {
810
Editor_Persistence: 'hlsjs:config-editor-persist',
911
Hls_Config: 'hlsjs:config'
@@ -116,14 +118,12 @@ $(document).ready(function () {
116118
// github PR for a pr
117119
function getVersionLink (version) {
118120
const alphaRegex = /[-.]0\.alpha\./;
119-
const prRegex = /[-.]pr\.([^.]+)/;
120-
const branchRegex = /[-.]branch\.([^.]+)/;
121121
if (alphaRegex.test(version)) {
122122
return `https://www.npmjs.com/package/hls.js/v/${encodeURIComponent(version)}`;
123-
} else if (prRegex.test(version)) {
124-
return `https://github.com/video-dev/hls.js/pull/${prRegex.exec(version)[1]}`;
125-
} else if (branchRegex.test(version)) {
126-
return `https://github.com/video-dev/hls.js/tree/${encodeURIComponent(branchRegex.exec(version)[1])}`;
123+
} else if (NETLIFY.reviewID) {
124+
return `https://github.com/video-dev/hls.js/pull/${NETLIFY.reviewID}`;
125+
} else if (NETLIFY.branch) {
126+
return `https://github.com/video-dev/hls.js/tree/${encodeURIComponent(NETLIFY.branch)}`;
127127
}
128128
return `https://github.com/video-dev/hls.js/releases/tag/v${encodeURIComponent(version)}`;
129129
}

webpack.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,16 @@ const multiConfig = [
214214
libraryExport: 'default',
215215
globalObject: 'this' // https://github.com/webpack/webpack/issues/6642#issuecomment-370222543
216216
},
217-
plugins: mainPlugins,
217+
plugins: [
218+
...mainPlugins,
219+
new webpack.DefinePlugin({
220+
__NETLIFY__: JSON.stringify(process.env.NETLIFY === 'true' ? {
221+
branch: process.env.BRANCH,
222+
commitRef: process.env.COMMIT_REF,
223+
reviewID: process.env.PULL_REQUEST === 'true' ? parseInt(process.env.REVIEW_ID) : null
224+
} : {})
225+
})
226+
],
218227
devtool: 'source-map'
219228
}
220229
].map(config => merge(baseConfig, config));

0 commit comments

Comments
 (0)