Skip to content

Commit

Permalink
morebits: insertAfterTemplates: Only throw if undefined aka not provided
Browse files Browse the repository at this point in the history
xiplus-mediawiki-programs/twinkle@f4fd970, Closes wikimedia-gadgets#1058

Co-Authored by: xiplus <huangxuanyuxiplus@gmail.com>
  • Loading branch information
Amorymeltzer committed Jul 21, 2020
1 parent 2b6f9a7 commit 50e51eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -4007,13 +4007,13 @@ Morebits.wikitext.page.prototype = {
* @returns {Morebits.wikitext.page}
*/
insertAfterTemplates: function(tag, regex, flags, preRegex) {
if (!tag) {
if (typeof tag === 'undefined') {
throw new Error('No tag provided');
}

// .length is only a property of strings and arrays so we
// shouldn't need to check type
if (!regex || !regex.length) {
if (typeof regex === 'undefined' || !regex.length) {
throw new Error('No regex provided');
} else if (Array.isArray(regex)) {
regex = regex.join('|');
Expand Down

0 comments on commit 50e51eb

Please sign in to comment.