diff --git a/README.md b/README.md index c91f7f8..0b2df02 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Done! - `https://disk.yandex.com/d/ahNF6_YRiAkeZA`—public (shared) file - `https://disk.yandex.com/d/RJJgoQNFJlWO9Q/baz.json`—file in a public (shared) folder - `https://disk.yandex.com/d/RJJgoQNFJlWO9Q/foo/bar/baz.json`—file in a subfolder of a public folder +- `https://disk.yandex.com/d/RJJgoQNFJlWO9Q/foo/bar`—file named `APP_ID.json` (where `APP_ID` is the name of your app) in a subfolder of a public folder **Note:** URLs starting with `https://disk.yandex.ru` are also supported. diff --git a/mavo-yandex.js b/mavo-yandex.js index 08708dc..a3507e4 100644 --- a/mavo-yandex.js +++ b/mavo-yandex.js @@ -243,11 +243,22 @@ const _ = Mavo.Backend.register( ret.filename = lastSegment; path.splice(path.length - 1, 1); } + + if (!ret.filename) { + ret.filepath = path.join("/") || (isPublic? "" : defaults.filepath); + } else { - ret.filename = !isPublic? defaults.filename : ""; + ret.filepath = path.join("/") || ""; } - ret.filepath = path.join("/") || (!isPublic? defaults.filepath : ""); + if (!ret.filename) { + if (ret.filepath) { + ret.filename = defaults.filename; + } + else { + ret.filename = isPublic? "" : defaults.filename; + } + } if (isPublic) { ret.publicKey = ret.rootPath; diff --git a/test.html b/test.html index c10b8d0..66f3817 100644 --- a/test.html +++ b/test.html @@ -40,6 +40,17 @@