Skip to content

Commit ba3c7ae

Browse files
fix assertString to throw TypeErrors on objects with custom constructor property
1 parent 9fa1e3a commit ba3c7ae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/lib/util/assertString.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default function assertString(input) {
22
if (input === undefined || input === null) throw new TypeError(`Expected a string but received a ${input}`);
3-
if (input.constructor.name !== 'String') throw new TypeError(`Expected a string but received a ${input.constructor.name}`);
3+
if (typeof input !== 'string' && !(input instanceof String)) throw new TypeError(`Expected a string but received a ${input?.constructor?.name ?? typeof input}`)
44
}

0 commit comments

Comments
 (0)