Skip to content

Commit

Permalink
Fix 'redundant character escape' warning using inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
dilame committed Apr 4, 2019
1 parent af8b735 commit c14ad5d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function main (usernameToFind, commentToFind, postUrl) {

let mediaId;

const re = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/;
const re = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/;

if (postUrl.match(re)) {
mediaId = postUrl.split('/')[4];
Expand Down
2 changes: 1 addition & 1 deletion src/v1/json-pruned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let seen; // Same variable used for all stringifications
(Date as any).prototype.toPrunedJSON = Date.prototype.toJSON;
(String as any).prototype.toPrunedJSON = (String as any).prototype.toJSON;

const escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
const escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;

const meta = {
// table of character substitutions
Expand Down
20 changes: 10 additions & 10 deletions src/v1/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export class Media extends Resource {
source_height: height,
},
});
payload = payload.replace(/\"\$width\"/gi, width.toFixed(1));
payload = payload.replace(/\"\$height\"/gi, height.toFixed(1));
payload = payload.replace(/\"\$zero\"/gi, (0).toFixed(1));
payload = payload.replace(/\"\$negativeZero\"/gi, `-${(0).toFixed(1)}`);
payload = payload.replace(/\"\$crop\"/gi, CROP.toFixed(1));
payload = payload.replace(/"\$width"/gi, width.toFixed(1));
payload = payload.replace(/"\$height"/gi, height.toFixed(1));
payload = payload.replace(/"\$zero"/gi, (0).toFixed(1));
payload = payload.replace(/"\$negativeZero"/gi, `-${(0).toFixed(1)}`);
payload = payload.replace(/"\$crop"/gi, CROP.toFixed(1));

return new Request(session)
.setMethod('POST')
Expand Down Expand Up @@ -167,11 +167,11 @@ export class Media extends Resource {
source_height: height,
},
});
payload = payload.replace(/\"\$width\"/gi, width.toFixed(1));
payload = payload.replace(/\"\$height\"/gi, height.toFixed(1));
payload = payload.replace(/\"\$zero\"/gi, (0).toFixed(1));
payload = payload.replace(/\"\$negativeZero\"/gi, `-${(0).toFixed(1)}`);
payload = payload.replace(/\"\$crop\"/gi, CROP.toFixed(1));
payload = payload.replace(/"\$width"/gi, width.toFixed(1));
payload = payload.replace(/"\$height"/gi, height.toFixed(1));
payload = payload.replace(/"\$zero"/gi, (0).toFixed(1));
payload = payload.replace(/"\$negativeZero"/gi, `-${(0).toFixed(1)}`);
payload = payload.replace(/"\$crop"/gi, CROP.toFixed(1));

return new Request(session)
.setMethod('POST')
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('`Device` class', () => {
});

it('should not be problem to get userAgent', () => {
const yellowstone = /^Instagram\s[0-9\.]*\sAndroid\s\(18\/4.0.4\;\s424dpi\;\s1080x1920\;\sGoogle\;\sYellowstone\;\syellowstone\;\sen_US\)$/;
const yellowstone = /^Instagram\s[0-9.]*\sAndroid\s\(18\/4.0.4;\s424dpi;\s1080x1920;\sGoogle;\sYellowstone;\syellowstone;\sen_US\)$/;
device1.userAgent().should.match(yellowstone);
});
});

0 comments on commit c14ad5d

Please sign in to comment.