Skip to content

Commit

Permalink
add trustedscriptlet tag
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 10, 2022
1 parent 69dc7c0 commit 9863ab2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const {
redirectsFilenames,
SCRIPTLETS_SRC_RELATIVE_DIR_PATH,
REDIRECTS_SRC_RELATIVE_DIR_PATH,
TRUSTED_SCRIPTLETS_TYPE,
} = require('./constants');

const STATIC_REDIRECTS_FILENAME = 'static-redirects.yml';
Expand Down Expand Up @@ -67,7 +66,7 @@ const manageDataFromFiles = () => {
.flat(Infinity);

const scriptletsData = fullData.filter(({ type }) => type === 'scriptlet');
const trustedScriptletsData = fullData.filter(({ type }) => type === TRUSTED_SCRIPTLETS_TYPE);
const trustedScriptletsData = fullData.filter(({ type }) => type === 'trustedscriptlet');
const redirectsData = fullData.filter(({ type }) => type === 'redirect');

return {
Expand Down
2 changes: 0 additions & 2 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const SCRIPTLETS_SRC_RELATIVE_DIR_PATH = `${SRC_RELATIVE_DIR}/${SRC_SCRIPTLETS_S
const REDIRECTS_SRC_RELATIVE_DIR_PATH = `${SRC_RELATIVE_DIR}/${SRC_REDIRECTS_SUB_DIR}`;

const TRUSTED_SCRIPTLETS_PREFIX = 'trusted-';
const TRUSTED_SCRIPTLETS_TYPE = 'trusted-scriptlet';

// files which are not scriptlets in the source directory
const NON_SCRIPTLETS_FILES = [
Expand Down Expand Up @@ -58,7 +57,6 @@ module.exports = {
WIKI_DIR_PATH,
SCRIPTLETS_SRC_RELATIVE_DIR_PATH,
REDIRECTS_SRC_RELATIVE_DIR_PATH,
TRUSTED_SCRIPTLETS_TYPE,
scriptletsFilenames,
trustedScriptletsFilenames,
redirectsFilenames,
Expand Down
12 changes: 2 additions & 10 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const getDescribingCommentTags = (filePath) => {
}
const [base] = tags;
return base?.type === 'scriptlet'
|| base?.type === 'trustedscriptlet'
|| base?.type === 'redirect';
});

Expand All @@ -68,16 +69,7 @@ Please add one OR edit the list of NON_SCRIPTLETS_FILES / NON_REDIRECTS_FILES.`)
}

// eventually only one comment data item should left
const { tags } = describingComment[0];

// Manually set type for trusted scriptlets
// to separate them from the common ones
if (filePath.includes('trusted-')) {
const [base] = tags;
base.type = 'trusted-scriptlet';
}

return tags;
return describingComment[0].tags;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-replace-fetch-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

/* eslint-disable max-len */
/**
* @scriptlet trusted-replace-fetch-response
* @trustedscriptlet trusted-replace-fetch-response
*
* @description
* Replaces response text content of `fetch` requests if **all** given parameters match.
Expand Down

0 comments on commit 9863ab2

Please sign in to comment.