diff --git a/manifest.json b/manifest.json index 3822b50..5d35f01 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-tweet-to-markdown", "name": "Tweet to Markdown", - "version": "1.1.0", + "version": "1.1.1", "minAppVersion": "0.12.16", "description": "Save tweets as Markdown files, along with their images, polls, etc.", "author": "kbravh", diff --git a/package.json b/package.json index 7aa29da..26300c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-tweet-to-markdown", - "version": "1.1.0", + "version": "1.1.1", "description": "Save tweets as beautiful markdown files in Obsidian (https://obsidian.md)", "main": "main.js", "engines": { @@ -24,5 +24,8 @@ "rollup": "^2.32.1", "tslib": "^2.2.0", "typescript": "^4.2.4" + }, + "dependencies": { + "sanitize-filename": "^1.6.3" } } diff --git a/src/util.ts b/src/util.ts index 0a68c6b..4d16c4d 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,7 @@ import {App, normalizePath, request, TAbstractFile} from 'obsidian' import {Media, Poll, Tweet} from './models' import {DownloadManager} from './downloadManager' +import sanitize from 'sanitize-filename' import TTM from 'main' import {TTMSettings} from './settings' @@ -94,9 +95,9 @@ export const createFilename = (tweet: Tweet, filename = ''): string => { filename = filename.replace('[[name]]', tweet.includes.users[0].name) filename = filename.replace('[[handle]]', tweet.includes.users[0].username) filename = filename.replace('[[id]]', tweet.data.id) - filename = filename.replace('[[text]]', normalizePath(tweet.data.text)) + filename = filename.replace('[[text]]', tweet.data.text) filename += '.md' - return filename + return sanitize(filename) } /** diff --git a/tsconfig.json b/tsconfig.json index 09cf7ec..38b2e68 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "noImplicitAny": true, "moduleResolution": "node", "importHelpers": true, + "allowSyntheticDefaultImports": true, "lib": [ "dom", "es5", diff --git a/versions.json b/versions.json index b0e432b..868b635 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.1.0": "0.12.16" + "1.1.1": "0.12.16" } diff --git a/yarn.lock b/yarn.lock index 1429992..df43666 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1880,6 +1880,13 @@ rxjs@^6.6.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +sanitize-filename@^1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.3.tgz#755ebd752045931977e30b2025d340d7c9090378" + integrity sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg== + dependencies: + truncate-utf8-bytes "^1.0.0" + semver-diff@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-3.1.1.tgz#05f77ce59f325e00e2706afd67bb506ddb1ca32b" @@ -2069,6 +2076,13 @@ trim-newlines@^3.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== +truncate-utf8-bytes@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b" + integrity sha1-QFkjkJWS1W94pYGENLC3hInKXys= + dependencies: + utf8-byte-length "^1.0.1" + tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -2171,6 +2185,11 @@ url-parse-lax@^3.0.0: dependencies: prepend-http "^2.0.0" +utf8-byte-length@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61" + integrity sha1-9F8VDExm7uloGGUFq5P8u4rWv2E= + v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"