1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Fixed regressions following fix for #1425

This commit is contained in:
Laurent Cozic
2019-05-11 12:08:28 +01:00
parent b702b0b40c
commit afb375955e
3 changed files with 24 additions and 21 deletions

View File

@@ -124,7 +124,10 @@ class BaseItem extends BaseModel {
static pathToId(path) {
let p = path.split('/');
let s = p[p.length - 1].split('.');
return s[0];
let name = s[0];
if (!name) return name;
name.split('-');
return name[name.length - 1];
}
static loadItemByPath(path) {

View File

@@ -178,14 +178,14 @@ class Note extends BaseItem {
const resource = await Resource.load(id);
if (!resource) continue;
const resourcePath = Resource.relativePath(resource)
body = body.replace(new RegExp(':/' + id, 'gi'), resourcePath); //toFileProtocolPath(Resource.fullPath(resource)));
body = body.replace(new RegExp(':/' + id, 'gi'), resourcePath);
}
return body;
}
static async replaceResourceExternalToInternalLinks(body) {
const reString = pregQuote(toFileProtocolPath(Resource.baseRelativeDirectoryPath() + '/')) + '[a-zA-Z0-9\.]+';
const reString = pregQuote(Resource.baseRelativeDirectoryPath() + '/') + '[a-zA-Z0-9\.]+';
const re = new RegExp(reString, 'gi');
body = body.replace(re, (match) => {
const id = Resource.pathToId(match);