Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
#338 Bug: no-http-string's description says start, but it checks for any
Browse files Browse the repository at this point in the history
closes #338
  • Loading branch information
HamletDRC committed Feb 2, 2017
1 parent be8c298 commit cc2d7f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/noHttpStringRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NoHttpStringWalker extends ErrorTolerantWalker {
protected visitStringLiteral(node: ts.StringLiteral): void {
const stringText : string = (<ts.LiteralExpression>node).text;
// tslint:disable no-http-string
if (stringText.indexOf('http:') !== -1) {
if (stringText.indexOf('http:') === 0) {
if (!this.isSuppressed(stringText)) {
const failureString = Rule.FAILURE_STRING + '\'' + stringText + '\'';
const failure = this.createFailure(node.getStart(), node.getWidth(), failureString);
Expand Down
5 changes: 5 additions & 0 deletions src/tests/NoHttpStringRuleTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe('noHttpStringRule', (): void => {
TestHelper.assertViolations(ruleName, inputScript, []);
});

it('should allow http in middle of string', (): void => {
const inputScript: string = 'var x = \'The prototcol may be http:// or https://\'';
TestHelper.assertViolations(ruleName, inputScript, []);
});

it('should allow https strings in default values', (): void => {
const inputScript: string = 'function f(x : string = \'https://www.microsoft.com\') {}';
TestHelper.assertViolations(ruleName, inputScript, []);
Expand Down

0 comments on commit cc2d7f4

Please sign in to comment.