Quote:
Originally Posted by KevinH
Checking if first digit is a number is quite easy and if so prepending a non-number will work just fine.
|
Is checking even necessary? if a uuid is guaranteed to be unique, then prepending any non-number to the value Utility::CreateUUID()'s returns would guarantee both uniqueness and a spec compliant id value, no?
Unless a non-standard uuid would break something somewhere else in Sigil, I'm thinking that changing Utility::CreateUUID() to the following would suffice:
Code:
QString Utility::CreateUUID()
{
return "s" + QUuid::createUuid().toString().remove("{").remove("}");
}
Or it could be done in OPFResource::GetUniqueID() if keeping Utility::CreateUUID() pure is necessary.
Code:
QString OPFResource::GetUniqueID(const QString &preferred_id, const OPFParser& p) const
{
if (p.m_idpos.contains(preferred_id)) {
return "s" + Utility::CreateUUID();
}
return preferred_id;
}