Skip to content

Commit

Permalink
Fixed reduceToURIChars
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jul 19, 2024
1 parent 165bfab commit 00b856b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/analysis/typepal/ConfigurableScopeGraph.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ bool defaultReportUnused (loc _, TModel _) {
return false;
}

// https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#:~:text=A%20URI%20is%20composed%20from,)%2C%20and%20the%20character%20%25%20.
// gen-delims: : / ? # [ ] @
// sub-delims: ! $ & ' ( ) * + , ;
// unreserved chars: a-z A-Z 0-9 - . _ ~
// percent: %

str legalInURI = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-,_~!$\'()*+;";
public set[str] legalInURIChars = { legalInURI[i] | i <- [0..size(legalInURI)] };

str reduceToURIChars(str s){
return visit(s){
case /^<c:[a-zA-Z0-9+\-\.\_\~:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\%\=]>/ => c
case str _ => ""
}
}
res = "<for(int i <- [0 .. size(s)]){><s[i] in legalInURIChars ? s[i] : "_"><}>";
//println("reduceToURIChars(<s>) =\> <res>");
return res;
}

loc defaultLogicalLoc(Define def, str _modelName, PathConfig _pcfg){
return def.defined; // return original and don't create logical location
Expand Down

0 comments on commit 00b856b

Please sign in to comment.