Seanny123 Seanny123 - 1 year ago 382
Javascript Question

Create SVG elements with TypeScript

I'm trying to create a properly formatted SVG element in TypeScript:

createSVGElement(tag) {
return document.createElementNS("", tag);

However, I get the following error in

Forbidden http url in string: ''

How do I avoid this error? I thought I required this URL to meet the SVG standard?

Answer Source

tslint is complaining due to the no-http-string rule. The rule is defined as:

Do not use strings that start with 'http:'. URL strings should start with 'https:'. Http strings can be a security problem and indicator that your software may suffer from cookie-stealing attacks. Since version 1.0, this rule takes a list of regular expressions as a parameter. Any string matching that regular expression will be ignored. For example, to allow http connections to and, configure your rule like this: "no-http-string": [true, "", ""]


Therefore, assuming you trust the World Wide Web Consortium, you could give it an exception in your tslint.json like

"no-http-string": [true, "*"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download