URIutil – Module with functions for strings in context of resource identifiers. This is not targeting for the subset, which is a locator formed as URL (see URLutil). In fact unique key codes for any kind of documents are covered: DOI, ISBN, ISSN, URN; furthermore some national and other codes like LCCN, GTIN/EAN, DNB, GND, ZDB, assigned by public institutions.
Functions for templates
All functions expect exactly one unnamed parameter (which should be provided to get a meaningful answer). Whitespace ahead and after content is ignored.
The return value is an empty string (“nothing”), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space.
coreISSN
7 significant digits of a 8-digit or 13-digit ISSN
formatISBN
Segmentation by hyphens; “X” capitalized.
formatISSN
Segmentation by hyphens; “X” capitalized.
Optionally: second parameter 8 or 13 for output format; else as got.
isDNBvalid
Is this DNB (also GND, ZDB) identifier formally correct, including check digit?
GND have at least 9 digits, not former 8 digits SWD and GKD with check digit separated by hyphen.
If a number with up to 7 digits a check digit separated by hyphen is following, a validation by rules before 2012 is tried.
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
administrate global updating and linking of module codes via Wikidata.
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
Parameter
Value
Result
current
nothing false
local version ID
»2024-08-05«
Minimal version
version ID required at least date in ISO format
It will be compared whether the current local implementation matches this version or later.
empty, if minimal version not achieved
2001-01-01 → »2024-08-05«
2099-01-01 →»«
wikidata
version ID of global upstream
version ID at Wikidata
local, if not found there
»2024-08-05«
item
ID of the Wikidata item
empty if not defined
Q19644443
~
Corresponding version ID locally and registered at Wikidata
empty, if up to date
version ID at Wikidata, if not equal
»«
@
Is the current (module) page linked correctly with Wikidata item?
empty, if linked to the item which is supposed
Iitem ID, if not
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.
Optional parameters
link=
The functions link* and uri* link the prefixed keyword/scheme to the assumed enzyclopedic article. The parameter value may specify an alternative page name; or link=0 would suppress linking.
nbsp=
The functions link* will use non breaking space between prefixed keyword and code; but nbsp=0 requests ASCII spaces.
Markup of bad codes
The functions link* and uri* assign class="invalid-ISBN" etc. to invalid codes. This might be utilized by users or gadgets for markup, e.g. a red box around the code.
All functions described above can be used by other modules:
locallucky,URIutil=pcall(require,"Modul:URIutil")iftype(URIutil)=="table"thenURIutil=URIutil()else-- failure; URLutil is the error messagereturn"<span class=\"error\">"..URIutil.."</span>"end
Subsequently there are available:
URIutil.coreISSN( attempt )
URIutil.formatISBN( attempt )
URIutil.formatISSN( attempt, achieve )
URIutil.isDNBvalid( attempt )
URIutil.isDOI( attempt )
URIutil.isEscValid( attempt )
URIutil.isGTINvalid( attempt )
URIutil.isISBN( attempt )
Second return value: table with ISBN components; number with error code
URIutil.isISBNvalid( attempt )
Second return value: table with ISBN components; number with error code